Make Ajax call even on sort?
Make Ajax call even on sort?
motormouthmike
Posts: 7Questions: 0Answers: 0
Hi
I'm using an ajax variable to populate my datatable. The problem is speed though in Internet Explorer.
In order to get around this, I only display the top 1000 records returned by the users search.
The problem is, that when the user then tries to sort some of the columns, the data is only searching the 1000 records and not the complete dataset.
Is there a function or variable I could set to ensure the new ajax call is made and the information is looked at again?
Alternatively is there a way to disable all search filters as part of a call back function?
[code]
"fnServerData": function ( sSource, aoData, fnCallback )
{
$.getJSON( sSource, aoData, function (json) {
if(json.limitedDataset == 1)
{
fnCallback(json);
alert('Your search with the following filters: ' + filtersMsg+ ' returns ' + json.iTotalDisplayRecords + ' results. Due to technical reasons the display is limited to 1000 records. Please apply additional filters to limit your results further.');
// Update current display
jQuery("#example_info").html(jQuery("#example_info").html() + ' ' + ' of a possible ' + json.iTotalDisplayRecords + ' results.');
// Update future calls via pagination
oTable.fnSettings().oLanguage.sInfoPostFix = ' of a possible ' + json.iTotalDisplayRecords + ' results.';
// How do i set bSort to false at this stage??
oTable.fnSettings().bSort = false;
}
else
{
$('#filters').show();
fnCallback(json);
}
[/code]
I'm using an ajax variable to populate my datatable. The problem is speed though in Internet Explorer.
In order to get around this, I only display the top 1000 records returned by the users search.
The problem is, that when the user then tries to sort some of the columns, the data is only searching the 1000 records and not the complete dataset.
Is there a function or variable I could set to ensure the new ajax call is made and the information is looked at again?
Alternatively is there a way to disable all search filters as part of a call back function?
[code]
"fnServerData": function ( sSource, aoData, fnCallback )
{
$.getJSON( sSource, aoData, function (json) {
if(json.limitedDataset == 1)
{
fnCallback(json);
alert('Your search with the following filters: ' + filtersMsg+ ' returns ' + json.iTotalDisplayRecords + ' results. Due to technical reasons the display is limited to 1000 records. Please apply additional filters to limit your results further.');
// Update current display
jQuery("#example_info").html(jQuery("#example_info").html() + ' ' + ' of a possible ' + json.iTotalDisplayRecords + ' results.');
// Update future calls via pagination
oTable.fnSettings().oLanguage.sInfoPostFix = ' of a possible ' + json.iTotalDisplayRecords + ' results.';
// How do i set bSort to false at this stage??
oTable.fnSettings().bSort = false;
}
else
{
$('#filters').show();
fnCallback(json);
}
[/code]
This discussion has been closed.
Replies
[code] jQuery("#example th").attr('class', 'sorting_disabled'); [/code]
Beyond that, you might want to look at server-side processing: http://datatables.net/usage/server-side
Allan
However, my search returns over 2000 records and some include large strings.
It seems datatables can't handle this in IE 7. Even cutting it down to 1000 records is quite painful.
Allan