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.

Component state in slot doesn't change when paging/sorting/filtering

See original GitHub issue

I have the following (products) table:

<b-table :fields="fields"
         :items="findAllProducts"
         :current-page="currentPage"
         :per-page="perPage"
         :filter="filter"
         :sort-by.sync="sortBy"
         :sort-desc.sync="sortDesc">

  <template slot="price" scope="data">
    <price-editable :product="data.item"></price-editable>
  </template>

</b-table>

findAllProducts is a provider function that does an http request based on the current page/sort/filter. price-editable is a custom component that renders an inline editable price field.

Now, when I do paging/sorting/filtering, the state (data) inside the price-editable component stays the same. It doesn’t re-render, but keeps the state of the ‘previous’ row.

How can I force to re-render a component inside a slot when paging/sorting/filtering?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

4reactions
jpkleemanscommented, Aug 28, 2017

@alexsasharegan @mosinve Thanks! Adding the :key="data.item.id" prop solved my problem. Really the kind of solution I was hoping for!

3reactions
alexsasharegancommented, Aug 26, 2017

Vue is really intelligent about reusing components for performance. Usually a new key would trigger a new component. Maybe try to add a key on your custom component based on your item id or something unique in your record.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React table with sorting and pagination doesn't update
First: don't assign state by this.state['arg']= . It's a bad practice. Use this.setState() instead. Second: this.setState() it's ...
Read more >
Python-Driven Filtering, Paging, Sorting
With backend paging, we can have front-end sorting and filtering but it will only filter and sort the data that exists on the...
Read more >
Table | Components
All click related and hover events, and sort-changed events will not be emitted when the table is in the busy state. Busy styling...
Read more >
Quasar Vue's QTable (3/6) - Loading State, Pagination, and ...
... and I'll teach you all 72 of Quasar's components ! ... Quasar Vue's QTable (3/6) - Loading State, Pagination, and Sorting.
Read more >
Table
The QTable Vue component allows you to display data in a tabular manner and ... If you don't need pagination, sorting, filtering, and...
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