How to get value of Input field in a datatable that is populated dynamically?

How to get value of Input field in a datatable that is populated dynamically?

AsthaMAsthaM Posts: 2Questions: 1Answers: 0
edited April 2019 in Free community support

I am using Datatables with my angular application. This is how I am populating my table:

 <tr *ngFor="let row of final_data; let i = index">
                  <td>{{row.name}}</td>
                  <td>{{row.id}}</td>
                  <td>{{row.age}}</td>
                  <td>{{row.phone}}</td>
                  <td>{{row.address}}</td>
                  <td><input id="newfield" [name]=i type="text" placeholder="Enter Goal"></td>
</tr>

Even when I use jQuery to get value by Name, I am only able to catch the first row and not the rest of the rows.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    edited April 2019 Answer ✓

    Even when I use jQuery to get value by Name,

    How are you doing this?

    Are you using row().data()?

    You can use rows().data() to get multiple rows.

    Kevin

  • AsthaMAsthaM Posts: 2Questions: 1Answers: 0

    I am using SerializeArray:

    var tbl = $('#mytable').DataTable();
    var params = tbl.$('input').serializeArray();

    Able to get the data now!

  • CrissLaglaCrissLagla Posts: 2Questions: 1Answers: 0

    I have the same problem some solution?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @CrissLagla ,

    This issue was resolved - did you check Kevin's solution? If this is still an issue for you, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.