I'm trying to get all values of my table by doing this:
var table = $('#myTableId').DataTable();
data = table.rows().data().toArray();
console.log( data );
for each row that I get, I get this:
id: "1"
fixedBalance: 345
balanceEditable1: "<div class='input-group'><span class='input-group-addon'>$</span><input value='75.0' type='number' min='0' class='form-control'/></div>"
balanceEditable2: "<div class='input-group'><span class='input-group-addon'>$</span><input value='7.00' type='number' min='0' class='form-control'/></div>"
description: "EXAMPLE 1"
id: "2"
fixedBalance: 147
balanceEditable1: "<div class='input-group'><span class='input-group-addon'>$</span><input value='2.30' type='number' min='0' class='form-control'/></div>"
balanceEditable2: "<div class='input-group'><span class='input-group-addon'>$</span><input value='12.20' type='number' min='0' class='form-control'/></div>"
description: "EXAMPLE 1"
As you see, I had to add an <input>
to make the Datatable cell editable for the balanceEditable1
and balanceEditable2
columns. But It is being hard to retrieve the value of it.
How could I get all the values of those inputs using de rows().data()
function and get the data like this?
id: "1"
fixedBalance: 345
balanceEditable1: 75.0
balanceEditable2: 7.00
description: "EXAMPLE 1"
id: "2"
fixedBalance: 147
balanceEditable1: 2.30
balanceEditable2: 12.20
description: "EXAMPLE 2"