invoke searching programmatically, custom searching
invoke searching programmatically, custom searching
dynamiclynk
Posts: 4Questions: 1Answers: 0
So I had the need to prevent the search box from posting to the server on each keydown. I created the below solution. Is there a better way to accomplish this?
I need take control of the search filter in my case.
referencing DT 1.10
$("#tblSupplier_filter input").keydown().off(); //detach current keydown handler
//attach my new event for searching
//you can change this to a button click event or another event of your choosing
$("#tblSupplier_filter input").keydown(function (keyData) {
if (keyData.which == 13) { //execute on keyenter
table.search($(this).val()).draw(); //pass whatever you want here
}
}).on(); //attach handler
This discussion has been closed.
Replies
That looks like a fair way of doing it. There are one or two plug-ins that take a similar approach in the plug-ins section. However, in 1.10, if you are using server-side processing, DataTables has a built in internal throttle, which should mean it won't hit the server on every key stroke, but still be quite responsive (not sure you use are using server-side processing...?).
Allan
Yes I am using server-side do you know of the DataTables property off hand for controlling the throttle timeout. I seen a couple of posts mention it, but they didn't indicate if this was controllable through the options.
Thanks.
There isn't one. You'd need to modify the code slightly. https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L2671
Allan