ColumnFilter fnServerData not called, so FilterDelay not working.

ColumnFilter fnServerData not called, so FilterDelay not working.

UrlUrl Posts: 5Questions: 0Answers: 0
edited December 2013 in Plug-ins
Hi everyone,

I am trying to put a delay on my search boxes so that not with every letter a ajax call is made, wich is very slow and can give high load. I am using the plugin ColumnFilter.js wich is working fine, but not I want to implement a delay and can't get it to work. I am initializing it like this:

[code]
var dataTable = $('#report_table').dataTable({
"bProcessing": true,
"bServerSide": true,
"aoColumns": data,
//Turn off sorting for the first operation_id column wich is not visible (boost performance when you dont sort)
"aoColumnDefs" : [ {
'bSortable' : false,
'aTargets' : [ 0 ]
} ],
"sScrollX": "100%",
//"sScrollXInner": "100%",
// "bDeferRender": true,
"sScrollY": tableScrollHeight + "px",
"bScrollCollapse": true,
"sAjaxSource": windowUrl + "/getjsondata/",
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$(nRow).on('click', function () {
window.open("report/rapportagereport/operation/" + aData[0],'_blank');

});
},
"oLanguage": {
"sUrl": "rapportage_tool/remaining_resources/dataTables.dutch.txt"
}
}).columnFilter();
[/code]

And in the columnFilter.js comment the original and uncomment the delay part like this:
[code]
oTable.fnServerData = function (sSource, aoData, fnCallback) {
console.log('ada');
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
var index = aiCustomSearch_Indexes[j];

for (k = 0; k < aoData.length; k++) {
if (aoData[k].name == "sSearch_" + index)
aoData[k].value = afnSearch_[j]();
}
}
aoData.push({ "name": "sRangeSeparator", "value": properties.sRangeSeparator });

// if (fnServerDataOriginal != null) {
// fnServerDataOriginal(sSource, aoData, fnCallback);
// }
// else {
// $.getJSON(sSource, aoData, function (json) {
// fnCallback(json)
// });
// }


if (fnServerDataOriginal != null) {
if (properties.iFilteringDelay != 0) {

if (oFunctionTimeout != null)
window.clearTimeout(oFunctionTimeout);
oFunctionTimeout = window.setTimeout(function () {
fnServerDataOriginal(sSource, aoData, fnCallback);
}, properties.iFilteringDelay);
} else {
fnServerDataOriginal(sSource, aoData, fnCallback);
}
}
else
$.getJSON(sSource, aoData, function (json) {
fnCallback(json)
});

};
[/code]
Now the problem is, is that my 'oTable.fnServerData' is never called somehow so the delay is never doing anything. I heard it had something to do with the oLanguage but when i comment that part I get the following error for some reason: 'Cannot read property 'sWidth' of undefined'. But and my table is not drawn correctly.

I also can't get the fnFilterDelay to work from datatables itself to work so I am out of options at the moment. I hope someone can help me with this issue.

Many Thanks!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Not entirely sure what the column filter plug-in is doing there (its 3rd party, and I don't know much about it), but if oTable is the table object, that I don't really see how that is going to work. If its the settings object, then I guess it might, but its definitely not a public interface that, so I think you'd need to add some console.log logged to see what exactly is going on.

    Sorry I don't have a better and more immediate answer.

    Allan
This discussion has been closed.