adding rows to a table dynamically and then getting the added rows

adding rows to a table dynamically and then getting the added rows

vyshvysh Posts: 1Questions: 0Answers: 0
edited October 2013 in DataTables 1.9
I am using this code to create a table
[code]
oTable = $('#table_id').dataTable();
[/code]

and then using [code] fnAddData() [/code] to add rows to it dynamically.

The requirement is to allow users to add multiple rows and then save the added rows on click of a "Save" button.
For getting the rows, I am using [code] fnGetNodes() [/code], but this does not return the dynamically added rows.
My guess is that since new rows are not written on to the HTML, so the Datatable API is not able to get the rows.

Any idea how I can get the entire table (old as well as dynamically added rows) ??

Any help would be greatly appreciated.

Replies

  • Mike_MikeMike_Mike Posts: 6Questions: 1Answers: 0
    I use fnAddData() to add dynamic rows, but then I am using:

    [code]
    var data = oTable.fnGetData(this);
    [/code]

    where 'this' can be replaced with a rowid, or a tr, or left out completely to get the whole table,

    try here: http://datatables.net/ref#fnGetData
  • jqueryIssuesjqueryIssues Posts: 9Questions: 2Answers: 0
    Hi

    I am also using fnAddData to create dynamic rows ,but I want text box,checkbox and button in columns of dynamically generated rows. Is it possible to do so ?
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Sure, just put the HTML that you want into the data to be displayed.

    Allan
  • jqueryIssuesjqueryIssues Posts: 9Questions: 2Answers: 0
    thanks Allan :-)
This discussion has been closed.