Scroller questions (not being able to select all rows by class)

Scroller questions (not being able to select all rows by class)

MurulokiMuruloki Posts: 2Questions: 1Answers: 0
edited March 2017 in Free community support

Hi,

I'm playing with DataTables right now (thanks for all the work!) and have a couple of questions.

My setup:
- I prepare all the rows data server-side and assign it to js variable (array of hashes). Let's say it's 10k of rows. Don't want to deal with Ajax headaches/slowness.
- On the client side, I initialize DataTable with Scroller and Select extensions and feed it js array
- I also use createdRow() to add various classes to the rows (say, active or inactive etc) based on the data

Now, everything works fine as far as scrolling goes. Selection when done manually also works fine. However it seems like Scroller extension breaks API somewhat. For example, say out of 10k rows all of them are inactive. createdRow() performed its job and assigned "inactive" class to all rows, easy way of confirming is to manually scroll all the way to the end looking at the background (inactive class changes background).

So let's say I want to select all inactive rows. I try

table.rows('.inactive').select();

but it never returns/selects all inactive rows (in this case 10k). Initially, if i don't scroll at all, it may return say 153 or so. If i scroll a bit, it will return more. Basically, it looks like I have to manually scroll all the way to the end to make it return all 10k rows.

Ok, so then i tried every() approach:

table.rows().every(function (rowIdx, tableLoop, rowLoop) {
  if(this.data().active == 0){
     console.log('hey there, inactive profile, trying to select!');
     this.row().select();
}
}); 

First of all, it's painfully slow (not feasible for 10k rows for sure, Firefox displays message to abort the script) and even when number of rows is much less, say 1k, it still doesn't work - I hit console.log inside if() no problem but this.row().select(); doesn't relaly do anything.

So basically, I'm having trouble selecting() all rows based on class and then retrieving them when user wants to do some action on selected rows. Any tips on this?

Thank you!

Answers

  • MurulokiMuruloki Posts: 2Questions: 1Answers: 0

    ok, setting deferRender to false fixes the problem.

This discussion has been closed.