meteor-tabular
meteor-tabular copied to clipboard
Update 'selector' and re-draw table
Hi all!!
I'm facing a problem which I don't know how to solve and I hope you can help me.
I've created a table with the 'selector' option, which filters the items depending on a concrete value (i.e. a project Id).
TabularTables.Actions = new Tabular.Table({
// other properties...
selector: function( userId ) {
// projectId is retrieved from the user
return { project: projectId };
}
});
As I navigate through the application, I may change that value and in that case, I want to refresh the data (as the selector has changed) and redraw the table with the new items, but I don't know if there is a way to update that selector 'on the fly'. As there are thousand of elements and I need them to be filtered in server-side, I can't use a template helper.
Do you know any solution for this kind of problem??
Thanks on advance!!
I've encountered the same issue.
Is there any progress or workaround on this? :)
I'm having a similar issue - I can only update the selector once. After that, it no longer redraws the table.
Looking inside the code, it seems that tabular's autoruns are not being rerun when the selector is updated. To solve for this, I put a template.currentData() inside each of the autoruns that exist in tabular.js.
This works for my purposes, but I'm not sure if there are adverse side effects of this, and am thus hesitant to create a pull request.
If the selector is changing, it seems like it should be a reactive selector on the client. All of the querying still happens on the server regardless of where the selector comes from.
If your selector is an object stored in a reactiveVar , you need to clone it after .get() before changing values.
.get() gives you a reference to the object, so modifying it directly before the .set() will prevent reactivity because you will end up with the same object.
This discussion is helpful : https://github.com/meteor/meteor/issues/4414#issuecomment-222032868
Hi use ReactiveDict(), and not ReactiveVar(). This is working correctly!
I'm noticing the server doesn't notice any changes from a ReactiveDict if all keys remain the same. Is there a solution to this?
I.e. {foo:'foo'} to {foo:'bar'} should reactively trigger the server to re-query but it does not.