Preventing Automatic Sorting on Input Box Clicks
Preventing Automatic Sorting on Input Box Clicks
muallimim
Posts: 4Questions: 2Answers: 0
I added input boxes to the bottom row of the table to enable searching by columns, and I wrote the corresponding JavaScript code for these boxes. The codes are functioning properly. However, the table is being sorted again based on the respective column every time the boxes are clicked, and I don't want it to perform this sorting each time.
ID | Name | Title |
---|---|---|
///////////////////////////
$('#clx_datatable').DataTable().columns().every(function() {
var that = this;
$('input', this.header()).on('change', function() {
if (that.search() !== this.value) {
that.search(this.value).draw();
}
});
});
Answers
Use
orderCellsTop
to move the sorting function to the top header row.Kevin