reactive-table
reactive-table copied to clipboard
Filter does not work in all cases
Check the demo and try to input "✘" or "partial" on filter, it is strange. EDIT: It filters everything - I'm supposing it's because you return html on these tds?
Hmm just read the source and you search on all fields that are on mongo. So, virtual columns can't be filtered, right?
That's correct, I made sorting use the virtual columns but forgot do the same for filtering. It shouldn't be too hard though. Thanks for noticing this.
I've been thinking on a solution and I probably it's easier doing a transform or using a package like https://github.com/dburles/meteor-collection-helpers instead creating the virtual columns in this package. What do you think?
Interesting, I hadn't seen that package. It looks like it could be useful but I don't see how it would help with filtering specifically. How are you thinking it would work?
It's working for me now with collection-helpers with dburles help: https://github.com/dburles/meteor-collection-helpers/issues/5#issuecomment-38373684 But sorting the column does not work =/
I do not need the fn to create the virtual column anymore :)
You'd need to change the code in sortedRows to fix the sorting, but it's not obvious how to do it. I'm using the presence of fn to decide how to sort, and that happens before getting the data so it wouldn't be possible to check for functions at that point.
I'm not sure but I think it might be easier to just implement filtering on virtual columns.
The reason I picked collection-helpers is because I didn't have to change your filter query at all. When you do collection.find(filterQuery) it's like the virtual column exists in the doc, but it actually does not, it's emulated it with the package transformation.
I think it was the clearest solution.
That is nice :)
So collection-helpers works in the filter query but not the sort query? I wonder how hard it would be to modify collection-helpers so the transforms would work with sorting...
I haven't seen the sorting code yet, but I will soon :)
hi guys, @gabrielhpugliese i did what you did here dburles/meteor-collection-helpers#5 (comment) but still i cant figure this out...i still cant filter on virtual columns.. how did you make this work?
That was a long time ago. Idk if it works with the current version, but that's the code: https://github.com/gabrielhpugliese/reactive-table/blob/076e8e2a3ef7f1900e8dbb1e289ee875b072230d/lib/reactive_table.js#L142-L158
If you want to try the whole thing togheter, it's the filter branch :)
Gabriel Pugliese CodersTV.com @coderstv
On Wed, Jul 30, 2014 at 11:11 PM, kelvin martin ligue < [email protected]> wrote:
hi guys, @gabrielhpugliese https://github.com/gabrielhpugliese i did what you did here dburles/meteor-collection-helpers#5 https://github.com/dburles/meteor-collection-helpers/issues/5 (comment) but still i cant figure this out...i still cant filter on virtual columns.. how did you make this work?
— Reply to this email directly or view it on GitHub https://github.com/ecohealthalliance/reactive-table/issues/44#issuecomment-50705158 .
@gabrielhpugliese @aslagle it's not in the filter branch anymore I am trying to search on a virtual field that's connected with collection-helpers, or am I doing something wrong ?
{
key: 'userID'
label: 'user'
fn: (value, object) ->
# here the getFullName is a collection helper on current collection
# sorting works fine / filtering doesn't
return object.getFullname()
}
This is taken from documentation -
By default, fields that use fn will be sorted by the result of this function. If you want to sort by the field's original value instead (for example, if you are making a date human-readable), set sortByValue to true on the field object.
Sorting is ok, what about filtering ?
@tagrudev I've meant it's in filter branch of my fork: https://github.com/gabrielhpugliese/reactive-table/tree/filter
@gabrielhpugliese hmm had some problems running that with meteor 1.0 but after I did it is not filtering by the virtual field :) either
Any ETA on when filtering will work on fn fields?
I worked around not being able to filter virtual columns by using a client-side table filter library called List.js (https://listjs.com)