aslagle / reactive-table

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

Related Custom Filter #458

Closed peeyushjss closed 7 years ago

peeyushjss commented 7 years ago

Hello @aslagle

I wanna ask something about custom filter. I made a new custom filter with the given code -

Template.filter = new ReactiveTable.Filter('city', ["city"]); ReactiveTable.Filter('city').set('Noida');

Can we set value in the array format in place of String? I mean to say If we want data show who's city is Noida and some else also. So How can I set it? eg:

Template.filter = new ReactiveTable.Filter('city', ["city"]); ReactiveTable.Filter('city').set(['Noida', 'Delhi']);

It's not working.

One more issue can we set more than one key, when show data in reactive table. eg-

{ key: 'barcodeScanner.connected', // barcodeScanner.connected && barcodeScanner.status label: 'Barcode Scanner', fn: function(value, object) { if (value) return new Spacebars.SafeString('

'); else { return new Spacebars.SafeString('
'); } } }

Please provide me solution as soon as fast. Thanks in advance.

is-undefined commented 7 years ago

Just go through the documentation you will find it, do some research before throwing questions. And you will see it AS SOON AS FAST

peeyushjss commented 7 years ago

@is-undefined I tried several things and also read documentation then asked question.

If you have any solution please provide me.

aslagle commented 7 years ago

For the first question, the custom filter won't work with anything except a string or a simple mongo selector like $gt, but you might be able to set the filterOperator in the overall table settings to "$or" and then use the string "Noida Delhi" to find rows that match either word.

For the second question, there can only be one key but you can access the value for any other key using the object argument - it contains all keys for that row.

peeyushjss commented 7 years ago

For the second question, there can only be one key but you can access the value for any other key using the object argument - it contains all keys for that row. I understand it but I have another point. concentrate on given line

key: 'barcodeScanner.connected', // barcodeScanner.connected && barcodeScanner.status

can we use as key : 'barcodeScanner.connected && barcodeScanner.status'

or can we use as key : 'barcodeScanner.connected || barcodeScanner.status'.

I tried object but custom filter works on the key.

peeyushjss commented 7 years ago

Thanks for reply @aslagle I have one more question related to custom filter.

If we don't have particular key in collection. filter not working. Can you have any solution for this.

aslagle commented 7 years ago

No, you can't use more than one thing in the key. You'll have to pick one of them, or create two custom filters, one for each key.

peeyushjss commented 7 years ago

Thanks for confirming me.