Pre-selecting rows

Pre-selecting rows

ascendantascendant Posts: 7Questions: 0Answers: 0
edited May 2013 in General
Hello, my question is a bit related to:

http://datatables.net/forums/discussion/6368/pre-selected-rows/p1

Basically, what I'm trying to do is have a row be "pre-selected" based on information received from the database.

Basically, I tried using the :eq() jQuery method as Allan suggested in that thread. What I found is that, that works fine, so long as the row is in the first "N" entries that are shown by default. If not, though, it won't work.

In other words, jQuery seems to only see which rows are currently being rendered on the screen. If my DataTable is "Showing 1-10 of 25 entries," and I call $('#myDataTable tbody tr') I only get 10 nodes back- specifically those 1-10 currently being shown.

So $('tbody tr:eq(0)') as suggested might work fine if it's the first row, but if it's $('tbody tr:eq(14)') then it won't do anything, because jQuery doesn't even see that many nodes at the moment.

Any suggestions on how I should deal with it? setting the "Show N Entries" such that all entries would be rendered at once isn't really an option. Ideally, it would be swell if I could somehow make it automatically page to the page with the "pre-selected" row- but the main thing is I just want it to be pre-selected whenever it does show up.

Thanks,
Chris

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Use the $ method - http://datatables.net/docs/DataTables/1.9.4/DataTable.html#$

    Allan
This discussion has been closed.