Default Column Filters
Default Column Filters
I would like to specify some default filter options.
My data loads from the server, so basically i want it to take the data from the input filters below each column and send that the first time the table loads.
How can i do that?
My data loads from the server, so basically i want it to take the data from the input filters below each column and send that the first time the table loads.
How can i do that?
This discussion has been closed.
Replies
oTable.fnFilter("Ebay",2);
oTable.fnFilter("2",6);
If i do it right after the declaration of the table, then i get the desired affect. Only problem is that i have done 3 calls to get there, i just wanted my table to load and send the column data on init.
Also, rather than specifying the index, why not be able to specify the column name for the searching?
Regards,
Allan
I've tried passing aoSearchCols a query parameter from the URI, and I was hoping this array would map back to sSearch, which my server scripts is using to filter down my AJAX response.
I'm also tried chaining fnFilter() after dataTable({ ... }).fnSetFilteringDelay(), but I run into a race condition, causing a JS error.
[code]
var initialFilter = [];
for (i=0, loopCounter = aoCols.length; i
"oSearch": {"sSearch" : "MyURLValue"}
The initial search works great, but when I change the URL parameter, I get the search stored in my cookie from "bSaveState." I see the correct value in "oSearch.sSearch", but the cookie value "wins."
Is there something else I have to pass to tell DataTables to use the oSearch in preference of the value in the cookie?
I'm using DataTables Version 1.8.2.
Here's my new code:
[code]
$(dataTableNode).dataTable({
"aoColumns": aoCols, {% if q %}
"oSearch": {"sSearch" : "{{q}}"}, {% endif %}
"bDeferRender": true,
"bProcessing": true,
"bServerSide": true,
"bStateSave": true,
"fnServerData": fnDataTablesPipeline,
"sAjaxSource": ajaxDTSource,
"sDom": 'Clfrtip'
})
.fnSetFilteringDelay(500);
[/code]
An alternative is to use fnStateLoadCallback to remove the filter (again you could put conditional code around that), as is handily shown in the fnStateLoadCallback callback (although not on a per column basis - but that is similar) :-)
Allan
DataTables is insanely flexible & configurable and I'd like to thank you for all your hard work with a donation soon!
Allan