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

Init table with selector

Open mazing opened this issue 9 years ago • 8 comments

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.

mazing avatar Dec 20 '15 08:12 mazing

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

aslagle avatar Dec 21 '15 02:12 aslagle

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?

mazing avatar Dec 21 '15 09:12 mazing

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

aslagle avatar Dec 21 '15 13:12 aslagle

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?

drewlsvern avatar May 13 '16 19:05 drewlsvern

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.

aslagle avatar May 14 '16 14:05 aslagle

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.

drewlsvern avatar May 16 '16 15:05 drewlsvern

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?

thearabbit avatar Jun 04 '16 10:06 thearabbit

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

aslagle avatar Jun 05 '16 23:06 aslagle