Get rowid from row object

Get rowid from row object

TronikTronik Posts: 120Questions: 27Answers: 1

Hi,

How can I get the row id when iterating through row objects as:

 var data = table.rows( { selected: true } ).data();

              $.each( data, function (id, value) {
                  
                     console.log(id); //Prints 0,1,2 etc instead of the rowId I need
                     console.log(value); //Prints object
 
               } );

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @Tronik ,

    console.log(id); //Prints 0,1,2 etc instead of the rowId I need

    Yep, that will just print the index into the data array, not anything to do with the contents of the array.

    The best bet would be to use rows().ids().

    Cheers,

    Colin

This discussion has been closed.