Search in current page using Datatables.row('#id',{page:'current'}) seems to search whole table

Search in current page using Datatables.row('#id',{page:'current'}) seems to search whole table

howesdahowesda Posts: 1Questions: 1Answers: 0

Link to test case: https://jsfiddle.net/6u45eahd/1/
Debugger code (debug.datatables.net):
Error messages shown: None
Description of problem:

I need to check to see if a row with an known ID is present on the page that datatables is currently displaying

I'm using the following code

  let target = table.row('#'+ ns.currentClientId, {page:'current'});

When I look at target.data() it always seems to contain the row identified by the "id" column, regardless of whether it is on the currently displayed page or not.

Am I misunderstanding / misusing the API?

Answers

  • colincolin Posts: 10,137Questions: 0Answers: 1,698
    edited November 20

    I think because you're explicitly asking for a record, it's ignoring the fact that it's not on that page. Probably the easiest way would be to do something like this:

          if ( table.rows({page: 'current'}).ids().toArray().includes('id_1')){
            $('#tiger').css('visibility','visible');
          }
    

    See here,

    Colin

Sign In or Register to comment.