How to programmatically fire row click?
How to programmatically fire row click?
n14463
Posts: 4Questions: 2Answers: 0
In my datatable, i am highlighting a row in "createdRow" callback as below -
"createdRow": function (row, data, index) {
var obj = getUrlVars();
if (data.T_ID == id) {
$(row).addClass('selected');
}
}
}
After, the initialisation is done, in the "initComplete" i want to programmatically click on that selected row
"initComplete": function (settings, json) {
var tbl = $("#tbl_dt").DataTable();
var row = tbl.row(tbl.rows('.selected'));
$(row).trigger('click'); //THIS DOES NOT WORK --- PLEASE SUGGEST
}
but the above doesn't work. I have tried couple of options, please help
This discussion has been closed.
Answers
Hi @n14463 ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Yup - that looks like it should work. We'd need a test case really. That said, if you are using the Select extension for DataTables you could just use
row().select()
.Allan