gpt4 book ai didi

javascript - 数据表搜索刷新后到第一页而不是当前

转载 作者:行者123 更新时间:2023-11-29 23:33:33 25 4
gpt4 key购买 nike

我正在使用 bootstrap 数据表来记录。但是当我在表格的第二页时,如果我刷新页面,它会将我重定向到表格的第一页而不是第二页,不知道如何解决这个问题。

$("#dataTablesFull, #dataTablesFull2, #dataTablesFull3, #dataTablesFull4").dataTable( {
"pageLength": <?php echo getConfigValue("table_records"); ?>,
"dom": '<"top"f>rt<"bottom"><"row dt-margin"<"col-md-6"i><"col-md-6"p><"col-md-12"B>><"clear">',
"buttons": [ 'copy', 'csv', 'excel', 'pdf', 'print' ],
"oLanguage": {
"sSearch": "<i class='fa fa-search text-gray dTsearch'></i>",
"sEmptyTable": "<?php _e('No entries to show'); ?>",
"sZeroRecords": "<?php _e('Nothing found'); ?>",
"sInfo": "<?php _e('Showing'); ?> _START_ <?php _e('to'); ?> _END_ <?php _e('of'); ?> _TOTAL_ <?php _e('entries'); ?>",
"sInfoEmpty": "",
"oPaginate": {
"sNext": "<?php _e('Next'); ?>",
"sPrevious": "<?php _e('Previous'); ?>",
"sFirst": "<?php _e('First Page'); ?>",
"sLast": "<?php _e('Last Page'); ?>"
}
},
"columnDefs": [ { "orderable": false, "targets": -1 } ] }
);
$("#dataTablesFullNoOrder, #dataTablesFullNoOrder2").dataTable( {
"order": [],
"pageLength": <?php echo getConfigValue("table_records"); ?>,
"dom": '<"top"f>rt<"bottom"><"row dt-margin"<"col-md-6"i><"col-md-6"p><"col-md-12"B>><"clear">',
"buttons": [ 'copy', 'csv', 'excel', 'pdf', 'print' ],
"oLanguage": {
"sSearch": "<i class='fa fa-search text-gray dTsearch'></i>",
"sEmptyTable": "<?php _e('No entries to show'); ?>",
"sZeroRecords": "<?php _e('Nothing found'); ?>",
"sInfo": "<?php _e('Showing'); ?> _START_ <?php _e('to'); ?> _END_ <?php _e('of'); ?> _TOTAL_ <?php _e('entries'); ?>",
"sInfoEmpty": "",
"oPaginate": {
"sNext": "<?php _e('Next'); ?>",
"sPrevious": "<?php _e('Previous'); ?>",
"sFirst": "<?php _e('First Page'); ?>",
"sLast": "<?php _e('Last Page'); ?>"
}
},
"columnDefs": [ { "orderable": false, "targets": -1 } ] }
);
$("#dataTablesFullDesc, #dataTablesFullDesc2").dataTable( {
"order": [[ 0, "desc" ]],
"pageLength": <?php echo getConfigValue("table_records"); ?>,
"dom": '<"top"f>rt<"bottom"><"row dt-margin"<"col-md-6"i><"col-md-6"p><"col-md-12"B>><"clear">',
"buttons": [ 'copy', 'csv', 'excel', 'pdf', 'print' ],
"oLanguage": {
"sSearch": "<i class='fa fa-search text-gray dTsearch'></i>",
"sEmptyTable": "<?php _e('No entries to show'); ?>",
"sZeroRecords": "<?php _e('Nothing found'); ?>",
"sInfo": "<?php _e('Showing'); ?> _START_ <?php _e('to'); ?> _END_ <?php _e('of'); ?> _TOTAL_ <?php _e('entries'); ?>",
"sInfoEmpty": "",
"oPaginate": {
"sNext": "<?php _e('Next'); ?>",
"sPrevious": "<?php _e('Previous'); ?>",
"sFirst": "<?php _e('First Page'); ?>",
"sLast": "<?php _e('Last Page'); ?>"
}
},
"columnDefs": [ { "orderable": false, "targets": -1 } ] }
);

$("a[data-tab-destination]").on('click', function() {
var tab = $(this).attr('data-tab-destination');
$("#"+tab).click();
});

最佳答案

您可能需要状态保存功能。它将包括分页在内的表格状态保存在 cookie 中,以便在返回页面或刷新页面时,它将保持其所在的状态。

datatable state save

$(document).ready(function() {$('#example').DataTable( {stateSave: true} );} );

关于javascript - 数据表搜索刷新后到第一页而不是当前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46744610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com