How would one loop through all visible rows when the scroll is used?
How would one loop through all visible rows when the scroll is used?
aber231
Posts: 15Questions: 7Answers: 0
We are using ScrollY on a table that can contain very large datasets, but need to be able to loop through all visible rows (rows that were not removed by typing into the Search box). Since scroll renders the table dynamically, and seems to only display about 100 rows at a time, how can this be accomplished? Thanks!
ScrollY
https://datatables.net/examples/basic_init/scroll_y.html
Answers
I'm not clear what you mean by looping through the visible rows - as shown in the example you linked to, you can scroll through the table.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hi Colin,
Thanks for the reply and I created a test case here, but there is not much there yet due to the initial part of the question being about visible rows (maybe this test case will come in handy for followup questions): http://live.datatables.net/yuciqafo/1/edit
Concerning visible rows, when the user searches a datatables table the filter kicks in and hides rows that don't match the filter. I'm interested in looping through the rows that remain visible after this filter occurs. For the use case, the users will filter the table rows (again, using the Search textbox) and then will be able to perform actions against the rows that remain.
Thanks!
Hey Colin, one other datapoint: we are using scoller and I updated the example here: http://live.datatables.net/yuciqafo/3/edit
We read that scroller dynamically renders only what the user needs to see, to accommodate larger datasets. So our goal is to allow the user to filter the large dataset, using the Search textbox at the top of the table, and then we programmatically loop through the rows in the table that are still visible (have not been removed due to the user's filter using the Search textbox).
We just need to know how the loop works since the rows aren't actually in the DOM yet (due to scroller.js). Thanks!
More information: we are using deferRender: true
I'm not sure I understand what you are tying to do. But maybe this will help. If you want to loop through all the filtered rows use
rows().every()
with theselector modifier
of{search: "applied"}
. This will work regardless of using scroller.Kevin