fooplugins / FooTable

jQuery plugin to make HTML tables responsive
https://fooplugins.com/plugins/footable-jquery/
Other
2.13k stars 640 forks source link

Multiple Filters #138

Closed bluebrat closed 7 years ago

bluebrat commented 10 years ago

Hi,

Is it possible to filter on several keys instead of one? I've tried a few ways but none work. I possibly missed something or does it support this?

Thanks!

bradvin commented 10 years ago

@bluebrat one way that I have got this working is by having a hidden input on the page that is hooked up to the footable filtering, and then have other inputs or dropdowns append their filter into the hidden input.

Or use the filtering API and build up the filter string from multiple controls and pass it in

bluebrat commented 10 years ago

@bradvin that's what I've tried. I manage the filters in an array so I can build them myself in any needed format.

I tried passing footable a string: "xxx yyy zzz", comma delineated: "xxx,yyy,zzz" or just calling footable filter individually several times. Even tried passing it a simple array of terms, but that threw an error.

My current workaround is using a simple jquery hide/show toggle using the footable data field I create at run time. Doesn't seem to interfere with footable's sorting.

steveush commented 10 years ago

@bluebrat check out the filtering demo and look at the script at the bottom of the page. There we hook into the 'footable_filtering' event and simply append additional filters to the original one. Tokens should be delimited using a space, we used this approach in the demo to keep our text input clear while still applying the status filter 'separately'. Normally just the text input should work for multiple tokens as long as they are separated by spaces.

bluebrat commented 10 years ago

@steveush @bradvin

Thanks a lot for your help so far. I still have an issue however.

I am calling the function $('table').trigger('footable_filter', {filter: newFilter}); and newFilter is my string made up of terms. This works to a point.

It doesn't seem to be working when you try to add more than one value to the filter for a single column.

Example: Say I have a table that has two columns, "Group" and "Gender".

If I try to filter by Boys, the filter works. If I try to filter by "Boys Girls", nothing shows up. I would expect both Boys and Girls to display.

However, if I combine values from the two columns, this works. So, if I filter by "Boys" from the Gender column and "Soccer" from the Group column, it works.

I have a data-value placed in the TD"s for both columns containing the appropriate value.

Does this make sense? Thanks for all your help!

schrizzity commented 10 years ago

It looks like what you are wanting is an "OR" filter and what you are currently getting is an "AND" filter.

When you provide the filter with two values (Boys, Girls), you're filtering the table for records WHERE Gender = Boys AND Girls.

In another table plug-in (datatables), the "OR" filter was achieved by providing a filter string which was structured like so, "Boys|Girls". It doesn't look like this is the way footables works.

rajaveernapu commented 10 years ago

Hi @steveush @bradvin

I have two dropdowns lists in my page,

column1,column2,column3,column4

On Selection of dropdown1, filter table based on text of column3 only On Selection of dropdown2, filter table based on text of column4 only and i have a textbox on my page, if i search from textbox then filter should work on all four columns?

Is it possible with the footable?

Please help me

Thanks Raj

suenot commented 10 years ago

I have the same problem as Raj.

kedano commented 10 years ago

Any ideas on how I could achieve a "OR" filter instead of a "AND" filter?

hereiam133 commented 10 years ago

bump

bradvin commented 10 years ago

OR filtering is not possible with the current filtering code. To get OR filtering working you would need to override the function "filterFunction" in footable.filter.js : https://github.com/bradvin/FooTable/blob/V2/js/footable.filter.js#L12

kedano commented 10 years ago

@bradvin What is the expected data from the filterFunction? I've tried to console.log the data without getting any further. I guess what I'm looking for is a "ANY" filter from the values in my array of data (further explained in #243 ).

jawaharraj commented 10 years ago

@bradvin Added to filter on specific column, filter based on date RANGE will be very use full. like date starting from 15 Jan 2014 to maximum date range available in footable. Thanks

ManUtopiK commented 9 years ago

I just made a pull request for this issue.
I want to say, my changes seems working well. But I think this filter plugin need speed improvement without using DOM to get text of a row for each value (AND and OR).
Aka, if I search for foo bar,example. The plugin get the dom for each rows to search for foo, then it get once again the dom for the rows that contains foo to search for bar. Then, with my changes, it get again the dom for each rows to search for example. Querying the DOM is not the faster way to do the stuff, so, it's why I think this plugin should be refactoring...

kedano commented 9 years ago

I solved this on #303 .