How to select all entries for any matching filters (OR logic across panes)
How to select all entries for any matching filters (OR logic across panes)
Live test case: http://live.datatables.net/tifugeto/1/edit?html,output
I'm trying to build an interface that allows users to select ALL records that match ANY selected filters. In the live example a user should be able to select L1, L2, or L3 from each category and have those selections treated as an "OR" rather than an "AND". For instance, if a user selects Cat A L3 and Cat B L3 I still want it to show 2 entries, not 0 entries. Is this possible using SearchPanes? I suspect it's not... If not, is there a better way to go about this?
I tried SearchBuilder, but I don't want to present such a complicated set of search options to the user. I want to confine their options to selecting one level from each category (like I'm doing with SearchPanes), but I don't see a way to do something similar with SearchBuilder.
Can anyone point me in the right direction? Has anyone modified SearchPanes to allow something like this? Otherwise, is it possible to create an interface with SearchBuilder that looks similar to what I have with SearchPanes? Thanks for your time.
This question has an accepted answers - jump to answer
Answers
I haven't used SearchPanes much but believe you are correct that it doesn't support OR searches. You can create a search plugin for this. This thread links to an example. There are other threads/examples showing OR searches.
Kevin
That's right. We do have an open ticket for this already (DD-1075 for my reference) and we'll report back here when there's an update.
Colin
Thanks for the reply Kevin.
Colin, the ticket is to add OR support across panes?
Yep, OR support. It won't be fixed in the immediate future, as we're focused on other areas right now, but hopefully before too long.
Colin
Understood, thank you!
Updated test case: live.datatables.net/tifugeto/4/edit?html,output
@kthorngren I took your advice to look into creating a search plugin. The plugin I have so far works when I statically code the columns, but I'd like to use the 3 dropdown menus to choose the columns. I have the values assigned to the choices, but I don't know how to update the search plugin with those choices when selected.
I'm thinking it needs to look something like this, but I can't get this to update when choices are made in the dropdown menu.
I'm completely new to Javascript so I'm sure it's something obvious...but I've been trying to figure this out for a while and I'm not getting anywhere. Any help would be appreciated!
You need to call
draw()
when the input values change to trigger a re-search.Allan
Thanks for your reply. I did try adding
.draw();
in several places, but I haven't been able to update the table with the dropdown choices. Where should that call go?Create a
change
event handler for your drop down lists. In the event handler call thedraw()
API. This example is a checkbox example but its callingdraw()
to run the search plugin:http://live.datatables.net/wenaxuti/1/edit
Kevin
Thanks @allan and @kthorngren ! There were a couple other things wrong with my Javascript that were messing things up as well, but your two replies helped me piece this together. Final working version: live.datatables.net/tifugeto/8/edit