reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

Returning Query Results Into Reactive Table

Open schordas opened this issue 10 years ago • 6 comments

I am having trouble using meteor reactive tables to view data. I don't want to display my entire meteor collection in the table because there is too much data, I only want to display the results of user queries on the collection. I tried accomplishing this through setting and getting session variables and querying the collection with them like this

    if (Meteor.isServer){
      ReactiveTable.publish("user-items", Items, function () {
         #get query session variables
         #return results from query
      });
    }

but this isn't working because the queries haven't been made on start up. I am aware that this may not be an issue with reactive tables, if so I am using them incorrectly but I am not sure how to fix it. Thanks

schordas avatar Feb 07 '15 22:02 schordas

ReactiveTable.publish is mainly for limiting the data that the client subscribes to at any one time, but still including all the data in the table. It would be tough to use Session variables in it since they're on the client, and the table doesn't give you a way to pass more arguments in the subscription.

If your user queries limit the data enough that you can download all the results to the client at once, you could write your own Meteor.subscribe and Meteor.publish, and use Items.find(query) as the collection in your reactiveTable template settings.

You might also want to check out some enhancements I'm working on for version 0.7.0 - you'll be able to define your own filters, outside the table, so you could create a filter from your Session variables or the user input and attach it to the table. This is only published as a beta and I may still make changes, but you can try it out by setting the version to 0.7.0-beta1. Here's some documentation for this feature: https://github.com/aslagle/reactive-table/tree/filter-enhancements#creating-your-own-filter

aslagle avatar Feb 08 '15 04:02 aslagle

In the beta version, the _id is enriched with an incremental search index ... will it stay or will it be removed in the release version? Any idea of the date?

As far as i understand, today the only way to filter on the client side by using server side feed features is to use this stuff. Provide an additionnal client selector regardless the new filtering options may be a great feature.

kk4sh avatar Feb 25 '15 13:02 kk4sh

The _id will be fixed - it's a bug that was fixed in v0.6.7, but hasn't been merged to the beta version yet. I expect to release it sometime in the next couple weeks.

If you're using a server-side collection with version 0.6, you can still use the regular filter box, and you can pass a selector into ReactiveTable.publish on the server-side.

What would you use the additional client selector for? It isn't possible to do filtering purely client-side with a server-side publication, because the client only has one page of results at a time. Even with additional custom filters, the filtering is done on the server. The only difference would be where you pass in the argument.

aslagle avatar Feb 25 '15 13:02 aslagle

Ok for the beta version. Sorry i havent well explained. Having a selector on the client is a nonsense with server side pub. The wanted aim is well to dynamically change the server selector from the client side...as done on the beta version, but not available on the current one.

kk4sh avatar Feb 25 '15 17:02 kk4sh

Ok, right, in the current version there's no way to change the selector from the client outside of using the main filter input.

In the beta version, I don't know that I'd add another option, but maybe it could allow putting plain selectors in the filters list.

aslagle avatar Feb 26 '15 03:02 aslagle

I am trying to use selector field, but it does not work.

I pasted this line:

        selector: { key: 'value'},

into settings of table.

gustawdaniel avatar Nov 12 '17 20:11 gustawdaniel