Update DataTables' internal data when changing a cell's content
Update DataTables' internal data when changing a cell's content
Test case here:
http://live.datatables.net/dajuyefe/1/edit
If you click my button at the top labelled 'Update Cell' it updates the content of the div within the first table cell. It does this directly using the ID attribute on the div. After it is done, entering 'Changed cell' in the search box brings up no records.
I understand why this is the case: I'm not telling DataTables that the cell data has changed by doing it this way. The reason I am doing it this way is because I am using the ajax option to load the table from JSON. Then there is some javascript that updates table data based on various external criteria, so I don't know what cell is being updated in advance. I have the ID of the div tag only.
Maybe the part I'm missing is how to put a unique ID on each cell when the table is built so that I can address the cell rather than my div. What I need to do is update the div content and also tell DataTables about the new value so that subsequent searches will find my new data. Can I tell DataTables to assign an id to the TD when it is created after the Ajax load? Or is there a way I can get a handle to a cell from the JQuery object I have for the DIV tag?
Answers
I think I need to use 'createdCell' to set some data attributes on the TD.
Yes that works. Sorry to trouble you!