How to programatically add class to row using it´s current ordering position?
How to programatically add class to row using it´s current ordering position?
Leo Bruno
Posts: 19Questions: 3Answers: 0
Hi:
I´m trying to add the "selected" class to the first row, uppon filtering the records.
But no matter which option I use, the affected row is always the first one on the dataset.
The goal is to autoselect the first row uppon filtering.
The filtering method is being called from an outside function.
I don´t use the select extension.
Here is how I´m doing:
function handleSearchChange(event){
table.DataTable().search(String(event.target.value)).draw()
table.DataTable().$('tr.selected').removeClass('selected')
table.DataTable().row(0, {order: 'current'} ).nodes().to$().addClass('selected')
}
Can someone help?
Thank´s in advance.
Answers
I changed the code to the following, and realized that this one is more appropriate.
But, I can´t get the first filtered row to get selected.
Done it!
This library is amazing !!!
The only thing it can´t do is to make rain.
srrsrsrsrsrs
Plenty of rain here in Scotland. I never thought to add such a feature
I'd suggest you cache the
table.DataTable()
response btw. It will make things a little faster. Other than that - nice one. Thanks for posting back with your solution.Allan