aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 138 forks source link

Init table with selector #324

Open mazing opened 8 years ago

mazing commented 8 years ago

Is it possible to initialize the table with a selector just like meteor-tabular?

I know I can create filters, but I just need to "pre-set" a selector.

With such feature it would also be possible to create a standalone filter package to work with reactive-table.

aslagle commented 8 years ago

Yes, reactive table works with cursors as well as collections, so you can use collection.find(selector) as the collection argument to the table.

mazing commented 8 years ago

But right now I have a collection name as collection argument because I want to use the server-side filtering. Will it still be possible to use server-side filtering if I specify a cursor as collection argument?

aslagle commented 8 years ago

Oh, I see. For server-side filtering you're right, you have to use the name. You can pass in the selector to ReactiveTable.publish on the server (ReactiveTable.publish(name, collection, selector)) if you never need to change the selector. If you want to change it from the client-side, you do need to create a filter, but you can pre-set it without using any UI components - see https://github.com/aslagle/reactive-table#creating-your-own-filter

drewlsvern commented 8 years ago

I am using a mongo aggregate function and I am dealing with a big collection and it doesn't play nice attempting to load on the client side. Is there anyway to use a cursor on the server side? Is there a way to limit the results stored on the client as meteor-tabular does?

aslagle commented 8 years ago

I wanted to support cursors on the server-side, but I couldn't figure out a way to add pagination and filtering options to an existing cursor. You have to pass in the collection and selector separately so it can make a new cursor with all the options.

If you're using ReactiveTable.publish, only the results for the current page will be stored on the client - If you're seeing more there's probably a bug in the subscription code. Or are you asking about a hard limit option on the server? There isn't one now but I think that would be easy to add.

drewlsvern commented 8 years ago

I am dealing with a collection with about 30,000 records. It was attempting to load all records on the client even though I only want 10 per page. When I have a few moments I am going to take a look at your code to see if I can find a way to support passing a cursor, rather than just the collection and selector separately.

thearabbit commented 8 years ago

I have the same problem for init table selector like selector in tabular. I use Reactive Table in server side, but I would like init selector in client via Session. I tried to crate own filter

// client
this.filter = new ReactiveTable.Filter('customerByBranchFilter', ['branchId']);

filter.set(Session.get('currentBranch'));

After that it work fine, but it don't show default filter search box. Have any solution?

aslagle commented 8 years ago

showFilter: true in the table settings will restore the default filter box, it's removed by default when you use your own filter.