How to access a cell in a datatable from input text field and refresh its content after modification
How to access a cell in a datatable from input text field and refresh its content after modification
Hello,
My question is probably simple but I cannot find the solution on the forum.
In fact, I have a datatable filled with json (from server side). One column contains an input text field which represents a numeric number.
Firstly, what is the best way to get the value from the input text field?
Actually I do it like that (ele is the input text field got when I press enter to validate the field):
var oInfo = $(ele).closest("tr"); // Get the current line in datatable
var oTable = $(oInfo).closest(".my-table").DataTable(); // Get the DatableTable object (from current line)
var currentRow = oTable.row(oInfo).index(); // Get the current row
oTable.cell(currentRow,3).data(); // Get the cell data (3 is the column number which contains the input text field)
Secondly, If I change the value in the input field, what is the way to "refresh" the datatable in order to make the column correctly sorted with the new value.
I have tried to change data-sort and data-search attributes on <td> tag but without success. I suppose I have to change internal datatable cell value but I don't know how to do this. With the method just above, using oTable.cell(currentRow,3).data(10); just erase the content of display propertie of the cell object.
I hope you will understand my questions (sorry for me bad english)
Have a nice day.
Replies
Hi Lolo,
I think this is a duplicate of your other question, which I just replied to. If not, please can you explain further.
Cheers,
Colin