1

here my code :

      <b-table
          hover
          :items="usergroupTable.datas"
          :fields="usergroupTable.fields"
          :sort-by.sync="sortBy"
          :sort-desc.sync="sortDesc"
          responsive="sm"
      >
        <template #cell(edit)="data">
          <b-button @click="editItem(data.id)">Delete</b-button>
          <b-button @click="editItem(data.id)">Edit</b-button>
        </template>
      </b-table>

Here my datas :

data() {
    return {
      usergroupTable: {
        filter: null,
        fields: [
          'edit',
          { key: 'usergroupname', label:'User Group Name' , sortable: true},
          { key: 'product', label:'Product' , sortable: true},
          { key: 'seatslimits', label:'Seats Limit' , sortable: true},
          { key: 'expirationdate', label:'Expiration Date' , sortable: true},
          { key: 'lastpayment', label:'Last Payment' , sortable: true},
          { key: 'nextpayment', label:'Next Payment' , sortable: true},
        ],
        datas: [
          { id: 5 ,usergroupname: 'IUT Bordeaux', product: 'Light', seatslimits: '20', expirationdate: '2021/08/01', lastpayment: '', nextpayment: '' },
          { id: 8, usergroupname: 'Admins', product: 'God', seatslimits: '', expirationdate: '', lastpayment: '', nextpayment: '' }
        ],
      }
    }
  },

I try to have add and editing button each row, but now Edit column is empty, i don't see my buttons.

Anyone have an idea of the problem ? Thanks !

8
  • Are you getting any JS errors? Also, that syntax isn't familiar to me but could you try <template v-slot:cell(edit)="data"> Commented Oct 30, 2020 at 10:15
  • Same problem with any error in console with your code <template v-slot:cell(edit)="data"> Commented Oct 30, 2020 at 10:24
  • I don't getting any JS errors Commented Oct 30, 2020 at 10:24
  • 1
    What version of Vue and BootstrapVue are you using? Commented Oct 30, 2020 at 12:07
  • 1
    BootstrapVue 2.0.0 or 2.0.0-rc.xx? Commented Oct 30, 2020 at 16:02

1 Answer 1

1

As mentioned in the comments, you're using version 2.0.0-rc.28 which has a different naming syntax for <b-table> slots.

The syntax you're using is only available in the 2.0.0 release and above, so if you want to use that you need to update.

If you can't upgrade and need to stay on your current version. The syntax is v-slot:['[field_key]'] for cells, v-slot:['HEAD[field_key]'] for head cells, and v-slot:['FOOT[field_key]'] for footer cells.

The reason you have to wrap it in brackets, is because that's the syntax for dynamic when using v-slot, and therefore the naming [field_key] isn't directly useable. Which is also why this naming syntax only exists in 2.0.0-rc.28. It's different in prior versions, and later versions.

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.