meteor-tabular icon indicating copy to clipboard operation
meteor-tabular copied to clipboard

Table reloads and goes back to page 1 on data update

Open glappen opened this issue 10 years ago • 2 comments

Hello,

We have encountered a strange problem where are using a Tabular table to represent a list of people who attended a meeting. So on the meeting template, there is a meeting object in the data context. Inside the meeting object is an array of objects containing the attendee ID's and if they attended the meeting or not. So we have a helper method dynamically building the selector for the table. Each row of the table is an Attendee object, and there's a button to say if they attended the meeting or not. When the button is clicked, we call a method that updates the meeting data on the server. This causes the meeting data to change, and via reactivity, the selector is reloaded, causing the table to reload and go back to page 1. This is annoying when the user wants to update several rows at once without having to navigate back to the correct page in the results each time. Is there anyway to tell tabular not to reload the data once it has been loaded (and explicitly ask it to reload when we add a new row?)?

Thanks so much for any input.

glappen avatar Jul 17 '15 16:07 glappen

I would need to see a full reproduction. If you mean that the client-side selector is updated, then it's expected that you want the table to reload. But otherwise it should not reload just because of a document added.

aldeed avatar Aug 06 '15 18:08 aldeed

I thought I was having the same bug, but turns out the problem was more interesting:

  • In my Tabular table, I had some render() functions that used Meteor.user()
  • One of the side effects of updating the Tabular items collection also stored some stats on the user object
  • Even though those updated parameters weren't used in the table, it was causing a re-render of the table (and going back to page 1)

The fix was using some caching for those user settings in the render() function, similar to this: http://stackoverflow.com/questions/29753641/make-meteor-reactive-to-specific-subitem-of-meteor-user

maxko87 avatar Oct 26 '16 01:10 maxko87