I
I
Igor2019-07-07 11:01:52
Bootstrap
Igor, 2019-07-07 11:01:52

How to add custom elements to b-table?

How to add custom elements to b-table?
b-table
If the data were static, then it would not be difficult to put the button.
The data is loaded into the table via API.
b-table supports Formatter callback .
But it is unlikely that this will help me.
I need to add a couple of buttons to each row and hang event handlers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2019-07-07
@IgorPI

In general, there is such a thing:
It is called "Custom data rendering"
There is an instruction on how to do this.
Extract from the instructions
Scoped slots give you greater control over how the record data appears. If you want to add an extra field which does not exist in the records, just add it to the fields array, And then reference the field(s) in the scoped slot(s).
Well something like this

<b-table
                        no-local-sorting hover show-empty
                        select-mode="multi"
                        selectedVariant="success"
                        :items="this.products.items"
                        :fields="this.products.fields"
                        @row-selected="rowSelected"
                        @filtered="filtered"

                >

                    <template slot="mybutton" slot-scope="data">
                        <b-button variant="outline-primary">Edit</b-button>
                    </template>

                    <template slot="empty" slot-scope="scope">
                        <div class="text-center">
                            <h5>Пусто</h5>
                        </div>
                    </template>
                </b-table>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question