oSearch { sSearch } for columns?
oSearch { sSearch } for columns?
Is there an equivalent for columns to define an sSearch value at initialization time?
My page allows query string parameters, and I'd like to pass them at init time to datatables, rather than have one draw of normal data, then run the fnFilter.
I guess I could write a variable in fnServerData with an intial value (which is then made to an empty string so later calls aren't affected). But perhaps there's a better way?
What I need is the equivalent of:
[code]
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
if (myinitvar != "") {
getoDataByName('mykeyvalue').value=myinitvar; //note: this function doesn't exit. it's hypothetical
myinitvar = "";
}
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
}
[/code]
My page allows query string parameters, and I'd like to pass them at init time to datatables, rather than have one draw of normal data, then run the fnFilter.
I guess I could write a variable in fnServerData with an intial value (which is then made to an empty string so later calls aren't affected). But perhaps there's a better way?
What I need is the equivalent of:
[code]
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
if (myinitvar != "") {
getoDataByName('mykeyvalue').value=myinitvar; //note: this function doesn't exit. it's hypothetical
myinitvar = "";
}
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
}
[/code]
This discussion has been closed.
Replies
the above works, but instead of myinitvar, using a text field that is already populated by PHP with the $_GET value.
I suppose this works, but is there a cleaner DataTable way?
But if you need to have initial filtering in different applications using datatables there is another approach - the serverside scipt. You could use your initial filtering if (sEcho==1). Right now i am thinking of adding such an option for my serverside script and configuration files for the datatable... Because this way (in my applications) each user could have his own predefined filtering for each table.