Update Row with 2D array
Update Row with 2D array
Is there a way to update one row in a dataTable with a 2D array? I load my dataTable up by using the aaData attribute at the beginning. The 2D array is a JSON object returned by my server. When I update a cell in the table I want to go back to the server, update the object, and then take the response (the updated object) and update the dataTable. My response comes back to me in the same format when I build the table so I was looking for a way to do a update on the specific row I just updated.
I'm really trying to avoid clearing and adding all data back to minimize screen flickering and to ensure that the row that I just updated doesn't shift.
Thanks in advance for ANY suggestion
-Bob
Replies
I'm slightly confused - is it a 2D array of strings or a 1D array of objects?
If you have the object for the row and you have a reference to the row you want to update then fnUpdate ( http://datatables.net/api#fnUpdate ) will do what you need - it will take the object and allow you to update the whole row using the original data format.
Allan
I re-read fnUpdate and now understand that I can pass my object to the update itself.
string : The data to be added to the table. This array must be of the same length as the number of columns on the original HTML table.
or
array strings | object : Data to update the row with
I didn't pick up on the | in the last statement.
Thanks Allan!