How to add "selected" class to the first row displayed when the page changes?
How to add "selected" class to the first row displayed when the page changes?

Hi:
I´m looking for a way to add the "selected" class (i´m not using the select extension), after the pagination changes.
I´have seen some instructions to use DrawCallBack, but it is fired BEFORE the page changes, so I´m lost.
How can I achieve this?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Allan
Hi Allan....
Thank you for answering.
It partially worked.
The dataset has two pages.
When I go to page 2, the first row is not selected.
Then when I go back to page 1, the first row get´s selected.
Well, it din´t work at all.
Inspecting the console.lod data, I could see that is the row at page 1 that is being selected, when page 2 is drawn.
I changed the jQuery selector to
'tr:first-child'
which works and'tbody tr:eq(0)'
which also works. See this example:http://live.datatables.net/nuhibola/1/edit
I'm not sure how Datatables processes the
:eq(0)
selector versus'tbody tr:eq(0)'
but there is something different as it seems to use the Datatables cache instead of what is in the DOM.Kevin
Thank you Kevin and Allan.
Ah yes sorry. I forget to add
{page: 'current'}
as the second parameter to myrow()
selector. Doh.Allan