question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting _rowVariant on a click does not update the <b-table> items

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
lmapiicommented, Mar 23, 2018

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)

2reactions
xorbiscommented, Jan 12, 2018

Adding this.$forceUpdate(); Solves the problem.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found