简体   繁体   中英

JQuery bootstrap datatable pagination issue

I have a datatable that consists 200+ records and 10+ pages. Pagination is working perfect when clicking on next and previous buttons. But I'm getting and issue when click specific page and try to go another page (eg: clicks on 1 page and then clicks on 5th page). It shows processing message and nothing happens.

I'm getting this error on console:

在此处输入图片说明

var oTable = $('#trip_infor_tbl').dataTable( {
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource":"trip/infor",
            "paging": true,
            "language": {
                "emptyTable":       "No rejected entries available in table",
                "info":             "Showing _START_ to _END_ of _TOTAL_ entries",
                "infoEmpty":        "Showing 0 to 0 of 0 entries",
                "infoFiltered":     "",
                "infoPostFix":      "",
                "lengthMenu":       "Show _MENU_ entries",
                "loadingRecords":   "Loading...",
                "processing":       "Processing...",
                "search":           "Search:",
                "zeroRecords":      "Select a batch number from the above list",
                "paginate": {
                    "first":        "First",
                    "previous":     "Previous",
                    "next":         "Next",
                    "last":         "Last"
                },
                "aria": {
                    "sortAscending":    ": activate to sort column ascending",
                    "sortDescending":   ": activate to sort column descending"
                },
                "decimal":          "",
                "thousands":        ","
            },
            "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
                oSettings.jqXHR = $.ajax( {
                  "dataType": 'json',
                  "type": "GET",
                  "url": sSource,
                  "data": aoData,
                  "success": fnCallback,
                  "error": function (e) {

                  }
                });

                if(oSettings._iDisplayLength != -1) {
                    page_no =  Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength );
                    selectall.push(new Array());
                }
            },
            "fnRowCallback": function( nRow, aData, iDisplayIndex , iDisplayIndexFull) {
                //console.log(aData[0]);

                selectall[page_no].push(aData[0]); 
                //console.log(page_no);
                //console.log(selectall[page_no]);
                $('#trip_infor_tbl tbody tr').each( function () {
                    if (jQuery.inArray(aData[0], aselected)!=-1) {
                        $(this).addClass('selected DTTT_selected ');
                    }
                });
                return nRow;
            },
            "fnDrawCallback": function ( oSettings ) { 
                if(oSettings._iRecordsTotal == 0) {

                    $("#trip_infor_tbl").find("td").remove();
                    $("#trip_infor_tbl tbody").append('<th class="odd"><td valign="top" colspan="8" class="dataTables_empty">No data available in table</td></th>');

                }
                if(oSettings._iDisplayLength != -1) {
                    page =  Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength );
                }
                selected_id.push(new Array());

                $('#addbtn').attr('disabled','disabled'); //hide add to approve button on load

                if (oSettings._iRecordsDisplay == 0) {
                    $('#addbtn').attr('disabled','disabled');
                }else{

                }
.................................................

尝试不使用“ bProcessing”行:true或/和“ bServerSide”行:true您的表不是很大,因此您不会注意到任何性能损失

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM