Selected Column
Selected Column
wuwu
Posts: 52Questions: 17Answers: 0
Hi, I am using below codes in getting the selected row value and it is working. But I want to know also what column user has clicked?
table.on('select', function (e, dt, type, indexes) {
if (type === 'row') {
$("#hiddenOperNum").val(table.rows({ selected: true }).data()[0]['CurrentOperNum']);
}
});
Answers
One option is to use
select.items
and setting it tocell
. Theindexes
parameter will then have thecolumn
androw
indexes. For example:https://live.datatables.net/lohabuye/1/edit
The example assumes you want to ultimately select the row. If the
cell
is selected it will deselect all the cells and userow().select()
to select the row of the clicked cell.Kevin
Another way to do this is to create a
td
click event and in the event select the row. For example:https://live.datatables.net/lohabuye/2/edit
It uses
cell().data()
to get the clicked cell's contents andcell().index()
to get thecolumn
index.Kevin