How can I create a custom column in Bootstrap-Vue?

Here is my code snippet:

      <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 are 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 have tried to add an editing button to each row, but the Edit column is empty and I cannot see my buttons. Can anyone help me troubleshoot this issue? Thank you!

Answer №1

The comments point out that you are currently utilizing version 2.0.0-rc.28, which employs a distinct naming structure for <b-table> slots.

This particular syntax is exclusive to the 2.0.0 release and beyond, so in order to utilize it, an update is required.

If upgrading is not an option and you need to stick with your current version, here is the syntax: v-slot:['[field_key]'] for cells, v-slot:['HEAD[field_key]'] for header cells, and v-slot:['FOOT[field_key]'] for footer cells.

The inclusion of brackets is necessary due to the dynamic nature of v-slot, rendering the name [field_key] unusable in a direct manner. This naming convention is unique to 2.0.0-rc.28 and differs from earlier and later versions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Javascript problem involving multiple scopes in closures

What is the most effective solution for addressing this issue related to closure in JavaScript? Here is a simple problem I am facing: I have 10 spans with onclick events (I want an alert showing the number of the span clicked on each click): var spans = ...

Rendering in React by cycling through an array and displaying the content

I have been working on displaying two arrays. Whenever the button is clicked, a new user is generated and added to the array. My goal is to render the entire array instead of just the newest entries. I've attempted various methods but haven't had ...

Database verification failed to trigger modal display

I am currently in the process of developing a registration form that has a specific condition - if a person is already registered, they should not be able to register again. My Request Below is the PHP MySQL query that I am using to check for existing en ...

Error message: Unable to access properties of undefined object (reading 'authorization')

This is a snippet of code that handles user authentication and authorization const bcrypt = require("bcryptjs"); const jwt = require("jsonwebtoken"); const userRepository = require("../repositories/userRepository"); const SALT ...

Adding Javascript and CSS files to the document dynamically

I've created a custom jQuery plugin, but I need it to verify if jQuery is already loaded. If not, I want the plugin to load jQuery along with a few other necessary JavaScript files. Additionally, I want it to check if a specific CSS file has been load ...

What is the best way to ensure that the operations are not completed until they finish their work using RX

Is there a way to make RXJS wait until it finishes its work? Here is the function I am using: getLastOrderBeta() { return this.db.list(`Ring/${localStorage.getItem('localstorage')}`, { query: { equalTo: fa ...

Issues with HTML marquee not functioning properly post fadeIn()

I am attempting to create a progress bar using the HTML marquee element. When the user clicks submit, I want to fadeIn the HTML marquee and fadeOut with AJAX success. However, when I click the submit button, the marquee does not fadeIn as expected. Here is ...

Executing an external script in Nuxt after re-rendering: Best practices?

Looking for a solution in Nuxt/Vue to properly execute an external script (hosted by a third party) after the DOM has successfully rerendered on every route. The challenge arises when using a script that dynamically adds elements to the dom, causing confl ...

The Javascript code I wrote is unable to detect the array element that was initially defined in Python

Trying to launch a new browser window through Selenium using driver.execute_script("window.open('');") However, the goal is to open a specific link provided by the user. For this purpose, extracted the link input from an array and inc ...

What is the best way to position a semi-circular donut graph in the center?

I am attempting to showcase a doughnut or semi-circle chart within a materialize card, which is a responsive div element. My goal is to present simple data and utilize the chart as a progress bar. I took inspiration from the example provided in the HighCh ...

Tips for dynamically displaying a Material UI dialog with smooth fade effects

I am currently developing a basic application that lists users. Whenever I click on a user, I want to display a dialog box with specific information about that user. I have attempted to achieve this using Material UI's Dialog component in different wa ...

An issue occurred while attempting to utilize fs.readFileSync

Attempting to change an uploaded image to base 64 format var file = e.target.files[0]; var imageFile = fs.readFileSync(file); var encoded = new Buffer(imageFile).toString('base64'); An error is encountered: TypeError: __W ...

Develop a unique method for loading AngularJS templates

When working with AngularJS, there are various ways to provide an external template, such as using a script tag or a separate HTML file on the web server. However, I am faced with a situation where I need to implement a custom logic for retrieving these ...

Encountering issues when adding information to a React table

Every time I try to submit data, I encounter an error message. Line 53: Expected an assignment or function call and instead saw an expression no-unused-expressions I am attempting to add user-submitted data onto a table as td elements. Could someon ...

Refresh Browser with Angular UI State Parameters

I'm seeking assistance on an issue I've encountered while using angularjs 1.5.5 and angular-ui-router 0.4.2. Specifically, when refreshing the browser, I face a problem that seems to be implementation-specific. Below is a sample code snippet of ...

What is the best way to verify the invocation of a Vuex Mutation within a Vue component?

Imagine you have a Vue component with a method structured like this: methods:{ doSomething(someParameter){ //potentially manipulate the parameter in some way this.$store.commit("storeSomething",someParameter); let someP ...

The typescript error TS2339 is triggered by the property 'webkitURL' not being found on the 'Window' type

Currently utilizing Angular 2 in a project that is compiled with TypeScript. Encountering an issue when attempting to generate a blob image: Error TS2339: Property 'webkitURL' does not exist on type 'Window' The TypeScript code causi ...

Tips for adjusting image and div sizes dynamically according to the window size

In my quest, the end goal is to craft a simplistic gallery that closely resembles this particular example: EXAMPLE: This sample gallery is created using Flash technology, but I aim to develop mine utilizing HTML, CSS & Javascript to ensure compatibil ...

After submitting the form, the delete button in Bootstrap 4 has transformed into an unusual shape

I have a panel on my page, inside the panel header there is a red delete button. The panel content includes a form with several buttons (the red delete button is not inside the form, but linked to it with the form="abc" attribute). In the image below, whe ...

jQuery efficiently handles large amounts of text data transfer (gradual loading)

The issue at hand: My website relies on jQuery AJAX (post) for navigation, meaning the page doesn't refresh every time a user moves to a different section. This setup requires me to fetch data using AJAX and present it dynamically. While this works w ...