Numbered rows with scroller and default sorting
Numbered rows with scroller and default sorting
Just sharing this solution because it took me quite a while to figure it out.
I'm using an ajax call, serverside setup and I have scroller turned on. I also have auto-sorting happening on each initial page load. Together, these were causing issues with getting a column with consistent numbers from 1 to the end of whatever the current view/results were because of the virtual pages Scroller users and because relying on the initial order of the results was not reliable due to the sorting on initial draw.
Finally, I landed on this, added inside the drawCallback, which seems to work great:
var info = api.page.info();
var start = info.start;
api.column(0, { page: 'current' }).nodes().each(function (cell, i) {
cell.innerHTML = i + 1 + start;
});
If you're using another column except the 1st one, just change 0 to whatever the column index is.