fnServerData is called by events not related to the DataTable.

fnServerData is called by events not related to the DataTable.

rstadlerrstadler Posts: 5Questions: 0Answers: 0
edited February 2014 in DataTables 1.8
My dataTable is using ServerSide processing. The table is located in a OWF Widget in the OWF Framework, where it is in the 2nd of 3 tabs.
The problem is, when I resize the the OWF WIdget frame, fnServerData gets called. WHen I switch tabs, fnServerData gets called.
The worst of this is then when switching tabs and coming back to the tab where my dataTable resides, the table will no longer re-render to
reflect the contents received from the server.

var tableOptions =
{
"aoColumnDefs": sseItsmScope.columns,
"aaSorting": [[ 0, "desc" ]],
"bDeferRender": false,
"bInfo": true,
"bSortClasses": false,
"bJQueryUI": true,
"iDisplayLength": 10,
"bAutoWidth": false,
"bStateSave": false,
"sPaginationType": "full_numbers",
"cache": false,

"bProcessing": true,
"bServerSide": true,
"sAjaxSource": url,


"fnServerData": function ( sSource, aoData, fnCallback )
{


// Fix for [2] problem issues which call fnServerData().
// -- Clicking TextExpand More/Less
// -- Clicking on another widget tab
if (( sseItsmScope.checkStackTrace ( "cybersa.TextExpand" ) == true ) ||
( scriptScope.tabs.isOpen ( scriptScope.ITSM_TAB ) == false))
{
// Every firing of this function requires incrementing sEcho.
sseItsmScope.serverFetchCount++; // sEcho needs help !!
return ( false );
}
else
{
aoData[0].value = sseItsmScope.serverFetchCount; // sEcho needs help !!

$.ajax({
"dataType": 'json',
"contentType": "text/plain",
"type": "PUT",
"url": sSource,
"data": JSON.stringify(aoData),

"success": function (json)
{
/.. do some stuff..
json.aaData = result;
json.sEcho = sseItsmScope.serverFetchCount++; // sEcho needs help !!

fnCallback(json);
}
}); // $.ajax({

} // if()
} // "fnServerData": function
}; // var tableOptions ...


sseItsmScope.dataTable =
$( "#" + sseItsmScope.tableId ).dataTable ( tableOptions );
$( "#" + sseItsmScope.tableId ).dataTable ( tableOptions );

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    fnServerData will be called whenever DataTables does a draw in server-side processing mode. We'd need a link to the page so I can investigate why it is being called.

    Allan
  • rstadlerrstadler Posts: 5Questions: 0Answers: 0
    fnDraw is the event that makes all this happen. So, that explains it, but I need a work-around.
    I cannot point you to my link because it is govt/non-public.
  • rstadlerrstadler Posts: 5Questions: 0Answers: 0
    dataTable.fnAdjustColumnSizing() was the total cause. When I stopped this call (since this function calls fnDraw() ). then all the erroneous calls to "fnServerData" stopped.
This discussion has been closed.