DataTable position reset after using fnAddData

DataTable position reset after using fnAddData

radarsevenradarseven Posts: 1Questions: 0Answers: 0
edited December 2010 in General
First off, Allan, thanks for this amazing resource!

I'm having some trouble using [code]fnAddData[/code]. Basically the scenario is, I'm initializing a DataTable on the first page load. From there, I've setup infinite scrolling manually (not using the built-in version in 1.7.5) and am calling a function that retrieves JSON data from the server and adds it to my DataTable.

The problem is, on redraw, the scrollbar position always gets reset to the top of the DataTable. How can I maintain the scroll position after using fnAddData?

Here is my initial setup code:

[code]
var theTable = $( 'table.sortable' ).dataTable({
'bPaginate': false,
'bLengthChange': true,
'bFilter': false,
'bSort': true,
'bSortClasses': false,
'bInfo': false,
'bAutoWidth': false,
'bStateSave': false,
'bRetrieve': true,
'aaSorting': [[ 1, 'desc' ]],
'aoColumns': [
{
'bSortable': true
},
{
'sType': 'date',
'bSortable': true
},
{
'sType': 'natural',
'bSortable': true,
'asSorting': [ 'desc', 'asc' ]
},
{
'bSortable': true
}
]
});
[/code]

Thanks for your help!

Replies

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    This plug-in API function might help: http://datatables.net/plug-ins/api#fnAddDataAndDisplay . There is also a standing redraw function available on that page which might interest you as well, as the method used there could be used to do what you are looking for as well.

    Allan
This discussion has been closed.