Intercepting specific event handling (pagination click)
Intercepting specific event handling (pagination click)
Hi,
is there a way to intercept the default datatables handling when user clicks on pagination button (to fetch next page for example). I would do a little bit of validation before getting new content from the server (using bServerSide = true;). So, if the validation goes wrong, i would display a message instead of fetching new data from the server.
Thanks.
is there a way to intercept the default datatables handling when user clicks on pagination button (to fetch next page for example). I would do a little bit of validation before getting new content from the server (using bServerSide = true;). So, if the validation goes wrong, i would display a message instead of fetching new data from the server.
Thanks.
This discussion has been closed.
Replies
"fnServerParams": function (aoData) {
//do validate
if (isValid() == false) {
//errors on page, just return
return false;
} else {
aoData.push(...);
etc..
}
Is there a correct way to do this?
Allan
So actually yes, in this case fnPreDrawCallback is not suitable... (it could be modified to restore the state of the table, but I think that's probably not trivial, since it would need to reset filtering, sorting, paging etc).
So in fact, the best way to pick up and intercept the paging change event is to have a custom pagination control that will do your check and then either go with it or not.
http://datatables.net/development/pagination - how to create a paging plug-in
http://datatables.net/plug-ins/pagination - already made plug-ins
https://github.com/DataTables/DataTables/blob/master/media/src/ext/ext.paging.js - the build in paging methods
Allan