undefined : table.rows({selected: true}).data()

undefined : table.rows({selected: true}).data()

AkashvinoAkashvino Posts: 15Questions: 8Answers: 0

HI All,

Request your help, the below function display the required value plus the string "undefined" eg: "undefinedName1Name2Name3".

Note :
The table is not empty
The column "Name" has data for all the rows.
The table is defined as var table = $("#Details").DataTable();
No column are hidden.

Code

function ( e, dt, node, config ) {
  var optItm;
  for (var i = 0; i < table.rows({selected: true}).data().length; i++) {
      optItm += table.rows({selected: true}).data()[i]['Name'];
  }
  alert(optItm);
}

From,
Vino.B

Answers

  • kthorngrenkthorngren Posts: 21,141Questions: 26Answers: 4,918

    Its probably the data()[i]['Name'] part. The [i] is not going to work as you are expecting. If you want to loop over all the {selected: true} rows the use rows().every().

    Kevin

This discussion has been closed.