Parameter of sSearch for data.push

Parameter of sSearch for data.push

mizunekomizuneko Posts: 6Questions: 0Answers: 0
edited August 2013 in General
I have trouble with long URLs for server-side datatables and a previous discussion helps me a lot.
http://datatables.net/forums/discussion/6535/simpler-shorter-urls-for-server-side-datatables/p1

I have a table with 28 columns and about 8000 records, that caused 2,423 bytes URL length. After own settings, URL length is shorter as 451.
The basic parameters are shown below:

[code]
"fnServerData": function (url, data, callback, settings) {
//clean up data and apply our server params
//dl = displayLength, ds=DisplayStart, sb=SortBy (e.g 0|asc, 3|desc, etc), sEcho
//get the sEcho value first - not sure where it is stored
var sEcho = '';
for (var i = 0; i < data.length; i++) {
if (data[i].name == 'sEcho') {
sEcho = data[i].value;
}
}
// basic params
data = [];
data.push({ "name": "sEcho", "value": sEcho });
data.push({ "name": "iColumns", "value": "28" });
data.push({ "name": "iDisplayStart", "value": settings._iDisplayStart });
data.push({ "name": "iDisplayLength", "value": settings._iDisplayLength });
data.push({ "name": "iSortCol_0", "value": "1" });
data.push({ "name": "sSortDir_0", "value": "asc" });
data.push({ "name": "iSortingCols", "value": "1" });

settings.jqXHR = $.ajax({
"url": url,
"data": data,
"success": function (json) {
$(settings.oInstance).trigger('xhr', settings);
callback(json);
},
"dataType": "json",
"cache": false,
"error": function (xhr, error, thrown) {
if (error == "parsererror") {
alert("DataTables warning: JSON data from server could not be parsed. " +
"This is caused by a JSON formatting error.");
}
}
});
[/code]

Now, I have trouble with sDom search.
data.push({ "name": "sSearch", "value": sSearch });
It didn't work.

If anyone knows value of sSearch, please let me know.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Use POST rather than GET. You can do that using sServerMethod .

    I'd make it the default if I could, but that would be a breaking backwards incompatible change... I made a mistake making the default GET...

    Allan
  • mizunekomizuneko Posts: 6Questions: 0Answers: 0
    Allan,

    Thank you for a quick response.

    POST method takes 4~5 s to render all data, on the one hand GET method takes only 200 ms.
    For a solution, I can hide sDom search, because filters for each columns were working by data.push.

    Thank you!
This discussion has been closed.