Set the search field's value and sort the dataTable
Set the search field's value and sort the dataTable
Majestic
Posts: 14Questions: 7Answers: 0
Hello,
I retrieve the cell's value on double click and set the search's value to the cell's value in order to sort by the cell's value.
The issue I have is the dataTable is not updating when I set the search's value, it only works when I type on keyboard.
Is there a way to make it works as I expected ?
Here's my code :
$(document).ready(function() {
$('#dataTables tbody').on('dblclick', 'td', function () {
searchValue = currentTable.cell(this).data();
});
});
'rowCallback': function(row, data, index) {
$(row).dblclick(function() {
$('#dataTables_filter input').val(searchValue);
});
}
Thank you !
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Instead of populating the search input value you want to use the
search()
API. Remove the code you put in the rowCallback and update your dblclick event to use the search API, for example:Kevin
You're right, I should have take a look to the search API. It's working fine !
Thank you Kevin, it's awesome !