Filtering server-side, URL doesn't get requested after filter

Filtering server-side, URL doesn't get requested after filter

peterrowpeterrow Posts: 4Questions: 0Answers: 0
edited May 2011 in General
Great library guys, but I'm having a problem and wondered if some one could advise.
I'm using DataTables in a .NET MVC app with everything done server-side. I've used it in many places with a filter box and that has worked, until now...

I have 2 pages 1 showing a full index of events and another dashboard page which shows events as well but in a cut down fixed page length way. In both cases I am using the same plug-in to set a delay between when the user types into filter box and the request is made to site.

So in my index page I have the following JS which works fine when you type into the filter box (i.e. after you stop typing for 500ms a request is made to my site):

[code]
$(document).ready(function () {
$("#eventIndexDataTable").dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Events/IndexDataTable",
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"bStateSave": true,
"sDom": '<"top"if>rt<"bottom"lp>',
"oLanguage": { "sEmptyTable": "No events" }
}).fnSetFilteringDelay(500);
});
[/code]

On my dashboard page I have the following JS where filtering does not make a request to my site when typing stops, however it does the initial load of data when the dashboard page is loaded so the URL is correct:

[code]
$(document).ready(function () {
$("#eventsDataTable").dataTable({
"bProcessing": true,
"bServerSide": true,
"bFilter" : true,
"bSort": false,
"sAjaxSource": "/Events/DashboardDataTable",
"iDisplayLength": 3,
"sPaginationType": "two_button",
"bStateSave": false,
"sDom" : '<"top"f>rt<"bottom"ip>',
"oLanguage": {
"sEmptyTable": "No events",
"sInfo" : "_START_ to _END_ of _TOTAL_",
"sInfoEmpty" : ""
}
}).fnSetFilteringDelay(500);
});
[/code]

Any ideas why the 2nd use of datatables is not filtering or things I should check?

Replies

  • peterrowpeterrow Posts: 4Questions: 0Answers: 0
    I should also add I am using version 1.7.6 of DataTables.
    Anybody have any ideas?
  • peterrowpeterrow Posts: 4Questions: 0Answers: 0
    Another thing which I negated to mention is that I have 2 datatables on the same page.

    The cause of the problem was that the person that put the other datatable in had set bFilter = false but then added .fnSetFilteringDelay(500) so when I typed into the filter input for my datatable putting a break line on the JS code that the fnSetFilteringDelay() method hooks up revealed that it was weirdly trying to apply it to the incorrect html table - but it some how seemed to realise it was wrong and didn't make a request to its ajaxSource either.

    So not sure whether this is a bug in DataTables or the dataTableExt.oApi.fnSetFilteringDelay plugin but if you set bFilter to false but the use the filtering delay plug in then all datatables on that page will not filter when using server-side processing.
This discussion has been closed.