Edit updating multiple tables at once, is there a way just to update one table?

Edit updating multiple tables at once, is there a way just to update one table?

lmartinezlmartinez Posts: 8Questions: 5Answers: 2

I have a page that uses multiple tables and some of those tables have the ability to edit rows. So when I am updating a row on a certain table, it is actually updating all the tables. Yes, there is a chance that tables have the same data in them.

I have a method that basically checks which table is open and returns that instance of the table that needs to be updated, example below

 $('#mydevicesTabContent .tab-pane.active').attr('id') == "alldevices") {
        currentOptionOpened = null;
        optionUpdatedFlag = false;
        return allDevicesTable;

The line of code i have to update the table is below:

  updateTable.row($('#mydevicesTabContent div.active #' + rows[i].DT_RowId)).data(rows[i]);

the object rows is the data of the rows that need to updated.

rows = updateTable.rows().data();

or

rows = updateTable.rows('.selected').data();

This above code actually updates all the tables that I have, which is not the result I expect. Is there another way to edit rows?

Thanks

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    edited December 2018

    I assume updateTable is set to all you Datatables with something like this?
    updateTable = $('.myTables').Datatable()

    If thats the case then t wouldn't surprise me that all the tables are updated.

    My suggestion is to use tables() to select the table you want to update.

    Kevin

This discussion has been closed.