Get rowid from row object

Get rowid from row object

TronikTronik Posts: 122Questions: 28Answers: 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,240Questions: 1Answers: 2,599

    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.