javascript - How to reset pagination in a JQuery datatable -


i have jquery datatable loads data via ajax request. there form table lets user filter results on server. when user changes filter form, call fnreloadajax() new filter data, , table redraws new, filtered results.

the problem have pagination sticks, if table no longer has enough items reach current page. if table had 20 items, , user on page 2 (10 items per page), , change filter 5 items returned, table displays no items , shows @ bottom:

showing 11 5 of 5 entries 

it's still on page 2 though there enough data 1 page.

i have found numerous posts trying preserve current page/row, none showing simple way reset pagination first page. simplest way this?

here's simplified version of code clarity:

$("#mytable").datatable({     bstatesave: false,     fnserverdata: function (ssource, aodata, fncallback) {         return $.ajax({             type: "post",             url: url,             data: {filter: filtervalue}         });     } });  $("#myform").submit(function(e) {     table.fnreloadajax();     return false; }); 

you explicitly jump first page after reloading, see http://datatables.net/api#fnpagechange

$("#myform").submit(function(e) {     table.fnpagechange(0);     table.fnreloadajax();     return false; }); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -