How to get a cell from a selected row in DataTables
How to get a cell from a selected row in DataTables
Jevison7x
Posts: 1Questions: 1Answers: 0
I have a table as follows:
var custTable = $("#customer-records-table").DataTable({
"paging": false,
"info": true,
"scrollY": 300,
columnDefs: [
{
type: 'currency',
targets: [5, 6]
}
],
/* Disable initial sort */
"aaSorting": []
});
Then I can get a row by using the id to select it:
var row = custTable.row('#customer-' + customerObj.customerId);
I still can't understand how to get the first, second and third cells/columns from the row,
and I will like to be able to update some of the cells. Thanks.
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use the
cell()
orcells()
selectors to get the cells. For example:will give you the data for the row matching the row selector given in column index 0.
cell().data()
can also be used as a setter to set values.Allan