fnGetAdjacentTr and serverside processing
fnGetAdjacentTr and serverside processing
I'm using the fnGetAdjacentTr and Serverside data. I can get next/previous records for any row on screen, but when I have a table of more then one page (pagination = full_numbers), it stops.
Is there a way to trigger loading the next/previous page, so fnGetAdjacentTr can continue fetching data?
Is there a way to trigger loading the next/previous page, so fnGetAdjacentTr can continue fetching data?
This discussion has been closed.
Replies
[code]
$.fn.dataTableExt.oApi.fnGetAdjacentTr = function ( oSettings, nTr, bNext )
{
/* Find the node's position in the aoData store */
var iCurrent = oSettings.oApi._fnNodeToDataIndex( oSettings, nTr );
/* Convert that to a position in the display array */
var iDisplayIndex = $.inArray( iCurrent, oSettings.aiDisplay );
if ( iDisplayIndex == -1 )
{
/* Not in the current display */
return null;
}
/* Move along the display array as needed */
iDisplayIndex += (typeof bNext=='undefined' || bNext) ? 1 : -1;
/* Check that it within bounds */
if ( iDisplayIndex < 0 )
{
if (oSettings._iDisplayStart > 0 )
{
// we are not on page one, go the previous page
oSettings.oApi._fnPageChange( oSettings, "previous" );
// Refresh page to get data
oSettings.oApi_.fnDraw(oSettings)
// return last Tr of this page
returnTR = oSettings.aoData[ oSettings.aiDisplay[ oSettings.aiDisplay.length-1 ] ].nTr;
return returnTR;
}
else
{
// no previous record
return null;
}
}
else if ( iDisplayIndex >= oSettings.aiDisplay.length )
{
// TODO
/* There is no next/previous element */
return null;
}
/* Return the target node from the aoData store */
return oSettings.aoData[ oSettings.aiDisplay[ iDisplayIndex ] ].nTr;
};
[/code]
When testing, I get the correct pagechange, and in firebug I can see I get the correct returnTR;
But within my javascript code, the returned TR is the last Tr of the page before switching! Any idea why the reference is swiching when returning??
I can see the page swiching happening on screen, so that seems to work.
Sorry to say, but there is simply no way that fnGetAdjacentTr will ever work with server-side processing.
Allan
Time permissing,I'll make a demo for it this