"this" in rows().every() not working as expected

"this" in rows().every() not working as expected

eric_remotenceric_remotenc Posts: 3Questions: 1Answers: 0

Why the follwing code shows "this.selected is not a function"

table.rows().every(function () {
  if (this.selected()) {
    this.select();        
  }
});

while this one works?

table.rows().every(function () {
  this.select();        
});

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Hi,

    I've just been trying to reconstruct this, but haven't been able to do so. This was my attempt and it runs successfully.

    Maybe you are using an old version of Select? row().selected() was introduced in 1.4.0, per its documentation.

    Failing that, we'd need a link to a test case showing the issue please.

    Allan

  • eric_remotenceric_remotenc Posts: 3Questions: 1Answers: 0

    You're absolutely right! I was using local js Select for DataTables 1.3.1 and didn't notice that.

    I really appreciate your reply and feel sorry for not showing a test case before. Now I'm aware of the existence of https://live.datatables.net/ and will try to recreate the problem myself next time. Thank you again. You really saved my day.

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin

    No worries. Great to hear that you got it working! Thanks for letting me know.

    Allan

Sign In or Register to comment.