0

I try to render a bootstrap tooltip (https://bootstrap-vue.js.org/docs/components/tooltip/) within a header of an element-ui table.

I use the custom header render method:

<el-table-column
  v-for="(column, index) in headers"
  :render-header="renderHeader"
/>

The following code renders as expected except of the id which is missing. For debugging purposes I added a class which renders as expected:

renderHeader(h, { column }) {
  return h(
    'div',
    {
      id: `tooltip-target__${column.property}`,
      class: 'some-class'
    },
    [
      column.label,
      h(
        'b-tooltip',
        {
          attrs: {
            triggers: 'hover',
            target: `tooltip-target__${column.property}`
          }
        },
        column.label
      )
    ]
  );
},
1
  • Is your column.property value unique across all rows of your table? And are you including Bootstrap and BootstrapVue's CSS? Commented Dec 3, 2019 at 15:06

1 Answer 1

1

The id needs to be defined inside the attrs object:

renderHeader(h, { column }) {
  return h(
    'div',
    {
      attrs: {
        id: `tooltip-target__${column.property}`
      }
      class: 'some-class'
    },
    [
      column.label,
      h(
        'b-tooltip',
        {
          attrs: {
            triggers: 'hover',
            target: `tooltip-target__${column.property}`
          }
        },
        column.label
      )
    ]
  );
},

I found a good example in the documentation: https://v2.vuejs.org/v2/guide/render-function.html#The-Data-Object-In-Depth

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

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.