4

I need to have a custom table header (title + svg + tooltip) for Element table. I am trying to use the 'render-header' function without luck. To be more specific - how to print the label + SVG (with tooltip on hover) for each column?

Html:

 <el-table-column property="name" label="Indicator" :render-header="appendTip">
        </el-table-column>

Script:

appendTip(h, { column }) {
      return h(
        "el-tooltip",
        {
          attrs: {
            effect: "dark",
            content: "Test",
            placement: "top"
          }
        },
        [h("el-button", ["Tooltip"])]
      );

Thanks.

2 Answers 2

4

This is my solution:

appendTip(h, { column, $index }) {
      // Function(h, { column, $index })
      return h("span", [
        column.label,
        h(
          "el-popover",
          {
            props: {
              placement: "top",
              // title: "hello",
              // width: "200",
              trigger: "hover",
              content: this.test(column.label)
            }
          },
          [
            h(
              "i",
              {
                slot: "reference",
                class: "el-icon-info"
                //style: "color:gray;font-size:16px;margin-left:10px;"
              },
              ""
            )
          ]
        )
      ]);

I used this as a reference: https://v2.vuejs.org/v2/guide/render-function.html

Sign up to request clarification or add additional context in comments.

Comments

0

I have modified little bit for my requirements, I do not need [i] button for popover, I needed popover on header text, so the syntax that worked for me is given below

appendTip: function (h, { column, $index }) {

var content = "Popover content"
if (column.property == "isrequired") {
    content = "Value is Required";
}
else {
    return column.label;
}

return h(
        "el-popover",
        {
            props: {
                placement: "top",
                // title: "hello",
                // width: "200",
                trigger: "hover",
            }
        },
        [
            content,
            h(
                "span",
                {
                    slot: "reference",
                },
                column.label
            )
        ]
    );
},

Thanks badigard for your answer, that helped me a lot.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.