Server side processing re-initilize datatable problem
Server side processing re-initilize datatable problem
chandrashekar
Posts: 8Questions: 0Answers: 0
Hi All,
i am new to jquery and datable. I am using the 1.7.3 and I am having issues with the tables re-initializing using the destroy code. i am doing server side processing for pagination and sorting.
datatable has following functions
[code]
oTable = $('#asatable').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bFilter": false,
"bRetrieve": false,
"bDestroy": true,
"bStateSave": false,
"sPaginationType": "full_numbers",
"sAjaxSource": 'mypage_json.jsp?fromDate='+fromDate+'&toDate='+toDate,
"sDom": 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
"fnServerData": function ( sSource, aoData, fnDataTablesPipeline ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnDataTablesPipeline
} );
},
"aaSorting": [[ 2, "desc" ]],
"oLanguage": {
"sLengthMenu": ' show 1020304050 per page',
"sZeroRecords": "No records to display" }
});
[/code]
i need to generate table after form is submitted, table and form are in same page.
on re-submitting the form table should be re-initializing with new data. this is working as expected.
but when i click on the header to sort, previous data is loading back.
i add this piece of code to clear cache on form submit. but this approach is not working.
[code]
var oCache = {
iCacheLower: -1
};
[/code]
please help me with any suggestion to solve this issue.
thanks
chandru
i am new to jquery and datable. I am using the 1.7.3 and I am having issues with the tables re-initializing using the destroy code. i am doing server side processing for pagination and sorting.
datatable has following functions
[code]
oTable = $('#asatable').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bFilter": false,
"bRetrieve": false,
"bDestroy": true,
"bStateSave": false,
"sPaginationType": "full_numbers",
"sAjaxSource": 'mypage_json.jsp?fromDate='+fromDate+'&toDate='+toDate,
"sDom": 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
"fnServerData": function ( sSource, aoData, fnDataTablesPipeline ) {
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnDataTablesPipeline
} );
},
"aaSorting": [[ 2, "desc" ]],
"oLanguage": {
"sLengthMenu": ' show 1020304050 per page',
"sZeroRecords": "No records to display" }
});
[/code]
i need to generate table after form is submitted, table and form are in same page.
on re-submitting the form table should be re-initializing with new data. this is working as expected.
but when i click on the header to sort, previous data is loading back.
i add this piece of code to clear cache on form submit. but this approach is not working.
[code]
var oCache = {
iCacheLower: -1
};
[/code]
please help me with any suggestion to solve this issue.
thanks
chandru
This discussion has been closed.
Replies
Does it work correctly without using the pipining? I presume it does, in which case there just needs to be a way to clear out the cache, which is probably just oCache.iCacheLower = -1 (although I've not tried it! :-) ).
Allan
Thanks for the response,
I have tried oCache.iCacheLower = -1 to clear cache, but i was not working,
pipining looks likes like
[code]
function fnDataTablesPipeline ( sSource, aoData, fnCallback ) {
var iPipe = 1; /* Ajust the pipe size */
var bNeedServer = false;
var sEcho = fnGetKey(aoData, "sEcho");
var iRequestStart = fnGetKey(aoData, "iDisplayStart");
var iRequestLength = fnGetKey(aoData, "iDisplayLength");
var iRequestEnd = iRequestStart + iRequestLength;
oCache.iDisplayStart = iRequestStart;
/* outside pipeline? */
if ( oCache.iCacheLower < 0 || iRequestStart < oCache.iCacheLower || iRequestEnd > oCache.iCacheUpper )
{
bNeedServer = true;
}
/* sorting etc changed? */
if ( oCache.lastRequest && !bNeedServer )
{
//alert(oCache.lastRequest)
for( var i=0, iLen=aoData.length ; i
Allan
I am new to this, so sorry if i am wrong. also iam spiting message because it dont allow more than 500 char
code for datatable
[code]
oTable = $('#asatable').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bFilter": false,
"bRetrieve": false,
"bDestroy": true,
"bStateSave": false,
"sPaginationType": "full_numbers",
"sAjaxSource": 'mypage.jsp?fromDate='+fromDate+'&toDate='+toDate,
"sDom": 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
"fnServerData": fnDataTablesPipeline,
"aaSorting": [[ 2, "desc" ]],
"oLanguage": {
"sLengthMenu": ' show 1020304050 per page',
"sZeroRecords": "No records to display" }
});
[/code]
[code]
var oCache = {
iCacheLower: -1
};
function fnSetKey( aoData, sKey, mValue )
{
for ( var i=0, iLen=aoData.length ; i
Allan
Allan
when i recreate new table with new data, then if i click to sort, its sorting for my previous sSource, my assumption was when i destroy data-table, sSource associated will also be removed.
Allan
in IE 7 i am not able to generated datatable.
"DataTables warning: JSON data from server failed to load or be parsed, this is most likely to be caused by a JSON formatting error"