DataTables Filtering with yadcf : multiselect AND tags
DataTables Filtering with yadcf : multiselect AND tags

Hi guys,
i'm trying to filter a column of my datables Table.
This column contain some kind of tags/keywords.
I want that we can select 1 or more tag in the header, and the table display only lines that match with ALL selected items.
For the filtering process i'm using yadcf plugin (https://github.com/vedmack/yadcf) with Select2 for the multiselect input.
here is my code exemple (sorry for the double inputs in the header, i can't display only one in this CodePen code, but it works exactly the same) :
http://codepen.io/Dravenrip/pen/ibzJE/
As you can see, my problem is on the third column. When you select 2 elements (or more) in the filter menu of this column you get lines that contains "element 1" OR "element 2". But i want line with "element 1" AND "element 2".
Can you help me to do that ?
I'm not a jquery expert ... and non english speaker as you can see ;-)
thanks a lot for your help !!!
Answers
Hi,
I don't think that it currently possible, because lets heave the following example,
First row have: item1, item2, item3, item4
Second row have: item4, item3, item2, item1
and from multi select you choose item1 and item4 or item4 and item1, given that selection, I can't really filter even with regex for presence of item1 and item4 because of the order (unless you know a way so please let me know)
BUT, I do have an idea how to solve your problem , I do have a custom_func filter that can be upgraded to multi select and to auto populated from the table and than in your custom filter function you will test row by row with something like this: loop for the selected values of multi select and check indexOf !== -1 and return true or false based on this
Hey Daniel,
Could you please post this this function?
It would be a killer feature, to filter combinations of tags when rows have multiple tags. E.g. filter rows with tag: 'Electronic' + tag: 'House' + tag: 'Minimal'.
Thanks!
@Vanilla , the custom function for multi select filter was implemented in yadcf some time ago, read docs (all in the following links)
https://github.com/vedmack/yadcf/blob/master/lab/jquery.dataTables.yadcf.js#L33
https://github.com/vedmack/yadcf/blob/master/lab/jquery.dataTables.yadcf.js#L40
and see showcase - first column (despite the fact its for custom_func, my guess is that you will get the general idea) , also you can go through the github closed issues to see other users related questions with jsfiddle/etc...)
Thanx, it works very well. :-)
@Vanilla can you please post the multi_select_custom_func function. I need the same but I don't get this...