Setting _rowVariant on a click does not update the <b-table> items
See original GitHub issueI’ve done a lot of research on how one would implement a simple row highlight when using b-table. After reading about everything in the documentation I understood that _rowVariant is an item property that does just that. So I implemented it like so:
<b-table :items="items" @row-click="rowClicked"/>
rowClicked(item, index, event) {
this.items[index]._rowVariant = "active";
}
The row does not get any class update in it’s DOM. So I added some other test like so (to update the name column):
rowClicked(item, index, event) {
this.items[index].name = "Clicked me!";
}
Still no update. So I looked it up more and saw item providers and the refresh() call. So I tried another test like so:
<b-table ref="table" :items="getItems" @row-clicked="rowClicked"/>
getItems() {
return this.items || [];
},
rowClicked(item, index, event) {
this.items[index]._rowVariant = "active";
this.$refs.table.refresh();
}
Still no success, am I doing something wrong or could it be a bug? Using: “bootstrap-vue”: “^1.4.0”, “vue”: “^2.5.13”,
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Bootstrap-vue - Setting table variant dynamically
I'm trying to change the variant of a table cell depending on the value of it. Unfortunately, the variant parameter will not take...
Read more >Table | Components - BootstrapVue
Avoid manipulating record data in place, as changes to the underlying items data will cause either the row or entire table to be...
Read more >Updating the Data for an LWC lightning-datatable isn't re ...
My guess is that the table doesn't know to update because you have specified a key field of id but you have not...
Read more >How to update Variant Parts with library? | Altium Designer
In a schematic sheet of the design, select the Tools ▻ Update From Libraries command from the main menu. In the Settings section...
Read more >table-layout - CSS: Cascading Style Sheets - MDN Web Docs
Cells in subsequent rows do not affect column widths. Under the "fixed" layout method, the entire table can be rendered once the first...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
that’s very strange … i can even reproduce it with a simple jsfiddle: https://jsfiddle.net/ouxzag5j/6/
for contributing - don’t know. the issue is closed already since the force-update should do the trick too (but forces re-rendering)
Adding
this.$forceUpdate();
Solves the problem.