oSearch { sSearch } for columns?

oSearch { sSearch } for columns?

fbasfbas Posts: 1,094Questions: 4Answers: 0
edited July 2011 in General
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]

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited July 2011
    *edit*

    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?
  • StephanStephan Posts: 20Questions: 0Answers: 0
    I guess fnServerData is the obvious way to go, if you want to add filtering for a _specific_(only once) xhr.

    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.
This discussion has been closed.