-
Hello,
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't believe it's possible without passing in a fields array. Assuming you're currently utilizing the auto generated fields by only passing in <b-table :items="items" :fields="fields" />
{
computed: {
fields() {
if(this.items.length === 0) return [];
const item = this.items[0];
return Object.keys(item).map(field => ({ key: field, sortable: true }));
}
},
data() {
return {
items: []
}
}
} The above example will generate a field array based on the first object in your This should create fields and enable sorting for all fields automatically based on your data. |
Beta Was this translation helpful? Give feedback.
I don't believe it's possible without passing in a fields array.
Assuming you're currently utilizing the auto generated fields by only passing in
items
.You could utilize the same method to generate a fields array which you can then pass to your table.
The above example will generate a field array based on the first object in your
items
array.It will then map the keys and add
sortable: true
to al…