Using pagination, but need a way to loop through ALL rows in JS

Using pagination, but need a way to loop through ALL rows in JS

jeffsjeffs Posts: 2Questions: 0Answers: 0
edited April 2014 in DataTables 1.9
I have a paginated table. It's being built dynamically based on the results of a database call, and includes a checkbox input. I have a submit button below the table. When this is clicked, I need to loop through all of the table rows, but it seems like I'm only able to iterate over the current rows that are visible on-screen, due to the pagination. So basically I may have 100 rows, but its only showing me rows 1-10 due to the pagination, which is expceted. But when i try to loop through the table contents, it only iterates through rows 1-10, instead of all 100 rows. Are there any API's or settings that will allow me to access all the rows? I need to be able to see if the user has checked any of those checkboxes, even if they are currently in one of the other "pages" of the table and not onscreen....


  • jeffsjeffs Posts: 2Questions: 0Answers: 0
    Nevermind I found what I was looking for. For anyone else that may be interested here's my solution:

    Instead of this: $('#table').dataTable() use this: var dataTable = $('#table').dataTable()

    Then, when looping through the contents, instead of this: $('#table tr').each(function(){})
    do this: $(dataTable.fnGetNodes()).each(function(){})

    Just to clarify, I'm using jQuery for my selectors and for the each() function. But the fnGetNodes() was exactly what I needed, as it basically provides access to the entire set of rows (nodes) that are used to set up the data table, not just the paginated ones. Perfect!
This discussion has been closed.