Bruno Sartori Bruno Sartori - 2 months ago 18
Javascript Question

How to get multiple input values inside one DataTables column?

I have a DataTables wich i need to set 2 inputs in the same column, i know how to get the value if there is one input per column as below:

var table = $('#example').DataTable();

table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var cell = table.cell({ row: rowIdx, column: 0 }).node();

console.log($('input', cell).val());
});


How can i get the two values ?

table.cell({row: rowIdx, column:0}).node().find('#inputOne');

Answer

Map the values to array

var values = $(cell).find(':input').map(function(){
    return this.value
}).get();
console.log(values);