Filter if vield value is in an ID list and after button click
Filter if vield value is in an ID list and after button click
Hello.
I have a datatable that utilizes multiple filters together and they work great. However, we'd like to add one more, the most important, which would be an input box. The data entered in this box would trigger an ajax call to retrieve a list of database returned IDs. These IDs will correspond to certain IDs in the rows that would be placed in a hidden field within the DataTable when it is drawn. We need the filter to then only select those rows with IDs that are in the ID list returned from the ajax call. I can return those IDs from the ajax call and place into JSON or into an array, or whatever is required (and fastest).
First, I don't want this filter triggered automatically when the user starts typing because it will utilize some full-text index logic to pull the list of IDs and I don't want to hose the system with multiple queries. I'd rather have this particular filter be tied to a button that the user can click to initiate this expanded filter/search and then have the logic trigger the filter therefter, in afnFiltering, or any other adequate mechanism.
I am assuming that a custom filter in afnFiltering could be utilized to select (return true) if the hidden ID for each row is in the ajax returned ID list. I've been asked not to redraw the table or repost.
Can anyone please provide some direction?
Thanks so much!
TxWeb
I have a datatable that utilizes multiple filters together and they work great. However, we'd like to add one more, the most important, which would be an input box. The data entered in this box would trigger an ajax call to retrieve a list of database returned IDs. These IDs will correspond to certain IDs in the rows that would be placed in a hidden field within the DataTable when it is drawn. We need the filter to then only select those rows with IDs that are in the ID list returned from the ajax call. I can return those IDs from the ajax call and place into JSON or into an array, or whatever is required (and fastest).
First, I don't want this filter triggered automatically when the user starts typing because it will utilize some full-text index logic to pull the list of IDs and I don't want to hose the system with multiple queries. I'd rather have this particular filter be tied to a button that the user can click to initiate this expanded filter/search and then have the logic trigger the filter therefter, in afnFiltering, or any other adequate mechanism.
I am assuming that a custom filter in afnFiltering could be utilized to select (return true) if the hidden ID for each row is in the ajax returned ID list. I've been asked not to redraw the table or repost.
Can anyone please provide some direction?
Thanks so much!
TxWeb
This discussion has been closed.
Replies
See: http://datatables.net/examples/server_side/custom_vars.html
For instance, say my table has the columns: name, dbID (hidden), someDetailCol, state, dateSomeday. These are not my columns but will easily illustrate what we need.
Assume the user has already filtered by date and state by utilizing some dropdowns for which we've created the appropriate filters. Assume they now see rows corresponding to hidden dbIDs 20-30. Now, they use an input box and type in some text, to filter further, and hit a button to engage this new filter. At that point, an ajax call would go to a page/service and a list of dbIDs 22,25,26,28,29 would be returned. At this point the new filter would then show the rows that correspond to these hidden IDs. This would be much easier than having to redraw the entire table and utilize much less system resources.
Can it be done?
Thanks!
TxWeb
I am thinking your fnFilter would like something like:
[code]
fnFilter('2|4|7|83|41', 2, true);
[/code]
This would be if the ajax call returned dbID 2,4,7,83 & 41 and your dbID column id was 2.
See:
http://datatables.net/api#fnFilter
Thanks!!