How to get data from controls within row?

How to get data from controls within row?

bnlprsdbnlprsd Posts: 1Questions: 1Answers: 0

I am adding rows dynamically to datatable which contains textbox control. I need to get the data entered by user in the textbox. I am able to iterate the rows using DataTable.data() method and able to get the input control. But I am not getting the value. This is how I tried

var dt = $("#dGroupTable").DataTable();data().each(function () { //iterate each row console.log($($(this)[0][0]).val()); });

Answers

  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin

    Don't use data() since that will get the cached value from the cells that DataTables holds, rather than a live DOM value (because that is slow).

    Instead use rows().nodes() to get the tr elements and then jQuery to get the inputs - e.g.

    $( 'textarea', table.rows().nodes() )
    

    Allan

This discussion has been closed.