Maintain Position with scrolling table when adding new rows
Maintain Position with scrolling table when adding new rows
amun1000
Posts: 7Questions: 1Answers: 0
Hi
We have a scrolling datatable (of alarms) however when a row is added the table always scrolls back to the top. I need the table to maintain the selected row position and viewport if a row is selected . I have tried using the fnDrawCallback but the table has already scrolled back to the top when this event is raised
Code within the fnDrawCallback:
[code]if (selectedId > 0) {
var tr = alarmTable.fnGetNodes(CURRENTROW.rowIndex - 1)
var container = $('.dataTables_scrollBody');
container.scrollTop(tr.offsetTop - $(container)[0].offsetTop);[/code]
TIA
Andrew
We have a scrolling datatable (of alarms) however when a row is added the table always scrolls back to the top. I need the table to maintain the selected row position and viewport if a row is selected . I have tried using the fnDrawCallback but the table has already scrolled back to the top when this event is raised
Code within the fnDrawCallback:
[code]if (selectedId > 0) {
var tr = alarmTable.fnGetNodes(CURRENTROW.rowIndex - 1)
var container = $('.dataTables_scrollBody');
container.scrollTop(tr.offsetTop - $(container)[0].offsetTop);[/code]
TIA
Andrew
This discussion has been closed.