84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
当配置了 ajax 后,我每次执行rerender后都重新请求数据,导致本来时第三页的,但重新渲染了后变回第一页了,有办法只重新渲染不重新请求ajax数据吗,或重新请求时仍然是第三页
I use datatable more, combined with the information you provided
ajax retrieves the data of the current page number
var dt = $('#datatable').DataTable({ ... }); dt.ajax.reload(null, false); //记得这两个参数
After F5, the current page number is still maintained. This requires a little skill. Use localhost.hash to save page number, sorting and other data
localhost.hash
Conditions:
Convenient operation tool for loading Hash: https://github.com/cowboy/jquery-bbq
https://github.com/cowboy/jquery-bbq
Follow this
var _config = { displayStart: 0, pageLength: 10, order: [], drawCallback: function( settings ) { //绘制好之后,将状态写到Hash上面,翻页,排序的时候也会保持状态 var config = { displayStart: settings._iDisplayStart, pageLength: settings._iDisplayLength, search: {search: settings.oPreviousSearch.sSearch}, order: [] }; settings.aLastSort.forEach(function(v){ config.order.push([v.col, v.dir]); }); $.bbq.pushState(config); }, ..... }; var config = $.bbq.getState(); config = $.extend(true, _config, config); var dt = $('#datatable').DataTable(config);
I use datatable more, combined with the information you provided
Refresh the data of the current page
ajax retrieves the data of the current page number
F5 refresh page
After F5, the current page number is still maintained. This requires a little skill. Use
localhost.hash
to save page number, sorting and other dataConditions:
Convenient operation tool for loading Hash:
https://github.com/cowboy/jquery-bbq
Follow this