Pagination stopped working

Pagination stopped working

Rawland_HustleRawland_Hustle Posts: 94Questions: 16Answers: 0
edited April 2022 in Free community support

Link to test case: https://themeadow.se/ntjperrors/
Debugger code (debug.datatables.net):
Error messages shown: No error message shown
Description of problem:
For some reason I can't go to any other page than the first one. Does it have something to do with the search panes?

$(document).ready(function(){

    var table = $('#errorTable').DataTable( {
        "ajax": {
           "url": "https://themeadow.se/ntjperrors/ErrorCalls.php",
           "dataSrc": ""
        },
        "dom": "P<'myfilter'f>rlBptip",
        "pageLength": 100,
        "fixedHeader": true,
        "order": [[ 1, "asc" ], [ 13, "desc" ]],
        "buttons": [
            'excel', 'print'
        ],
        "searchPanes": {
            "cascadePanes": true,
            "i18n": {
                "emptyMessage": "Data saknas"
            },
            "panes": [
                {
                    "header": "Snabbfilter",
                    "options": [
                        {
                            "label": "Anrop där logisk adressat saknades i NTjP",
                                "value": function(rowData, rowIdx) {
                                    return rowData.LogicalAddress && rowData.LogicalAddressDescription == null;
                                }
                        },
                        {
                            "label": "Tidböcker där tjänstekontrakt saknades i NTjP",
                                "value": function(rowData, rowIdx) {
                                    return rowData.ServiceConsumerHsaId === "SE2321000016-92V4" && rowData.ServiceContract.startsWith("urn:riv:crm:scheduling") && rowData.ErrorCode === "VP004";
                                }
                        }
                    ],
                    "dtOpts": {
                        "searching": false,
                        "order": [[1, "desc"]]
                    }
                }
            ]
        },
        "columns": [
            {"data": "ServiceConsumerHsaId"},
            {"data": "ServiceConsumerDescription"},
            {"data": "ServiceContract"},
            {"data": "ServiceContract"},
            {"data": "LogicalAddress"},
            {"data": "LogicalAddressDescription"},
            {"data": "ErrorCode"},
            {"data": "ServiceProducerHsaId"},
            {"data": "ServiceProducerDescription"},
            {"data": "EndpointUrl"},
            {"data": "SnapshotTime"},
            {"data": "FailedRequests"},
            {"data": "SuccessfulRequests"},
            {"data": null}
        ],
        "columnDefs": [
            { "width": "25%", "targets": "ServiceConsumerDescription" },
            { "width": "25%", "targets": "LogicalAddressDescription" },
            { "width": "25%", "targets": "ServiceProducerDescription" },
            {
                "targets": [ "EndpointUrl", "SnapshotTime", "ServiceConsumerHsaId", "ServiceProducerHsaId" ],
                "visible": false,
                "searchable": false
            },
            {
                "targets": [ "ServiceDomain" ],
                "visible": false,
                "searchable": true,
                "data": "ServiceContract",
                "render": function ( data, type, row, meta ) {

                    if (data === 'null') {
                        return data;
                    } else {
                        data = data.split( ":" );
                        data = data.slice(0, -2);
                        data= data.join(":");
                        data = data.replace("urn:riv:","");
                        return data;
                    }

                }
            },
            {
                "targets": [ "ErrorPercent" ],
                "searchable": true,
                "data": "ServiceContract",
                "render": function ( data, type, row, meta ) {

                    return percentage(row.FailedRequests, row.SuccessfulRequests);

                }
            },
            {
                "targets": "ServiceContract",
                "data": "ServiceContract",
                "render": function ( data, type, row, meta ) {

                    if (data === 'null') {
                        return data;
                    } else {
                        data = data.split( ':' );
                        var version = data[data.length - 1];
                        data = data[ data.length - 2 ];
                        var substringToRemove = "Responder";
                        data = data.slice(0,-(substringToRemove.length));
                        return data + " v" + version;
                    }

                }
            },
            {
                "searchPanes": {
                    "show": true
                },
                "targets": ["ServiceConsumerDescription", "ServiceConsumerDescription", "LogicalAddressDescription", "ErrorCode", "ServiceProducerDescription"]
            },
            {
                "searchPanes": {
                    "show": false
                },
                "targets": ["ServiceConsumerHsaId", "LogicalAddress", "ServiceProducerHsaId", "EndpointUrl", "SnapshotTime", "FailedRequests", "SuccessfulRequests", "ErrorPercent"]
            }
        ],
        "rowGroup": {
            "dataSrc": "ServiceConsumerDescription"
        },
        "language": {
            "decimal":        "",
            "emptyTable":     "Ingen data tillgänglig i tabellen",
            "info":           "Visar _START_ till _END_ av _TOTAL_ rader",
            "infoEmpty":      "Visar 0 till 0 av 0 rader",
            "infoFiltered":   "(filtrerat från _MAX_ rader)",
            "infoPostFix":    "",
            "thousands":      ",",
            "lengthMenu":     "Visa _MENU_ rader",
            "loadingRecords": "Laddar...",
            "processing":     "Bearbetar...",
            "search":         "Sök:",
            "zeroRecords":    "Inga matchningar",
            "paginate": {
                "first":      "Första",
                "last":       "Sista",
                "next":       "Nästa",
                "previous":   "Föregående"
            },
            "aria": {
                "sortAscending":  ": Aktivera för att sortera stigande",
                "sortDescending": ": Aktivera för att sortera fallande"
            },
            "searchPanes": {
                "loadMessage": 'Laddar filtreringspaneler...',
                "title": {
                    _: '%d filter valda',
                    0: 'Inga filter valda',
                    1: 'Ett filter valt'
                },
                "collapseMessage": 'Fäll in',
                "showMessage": 'Visa',
                "clearMessage": 'Rensa'
            }
        },
        "drawCallback": function( settings ) {

            var api = this.api();

            var totalNumberOfFailedRequests = api.column( 11, {filter:'applied'} ).data().sum();
            var totalNumberOfFailedRequestsPrettified = totalNumberOfFailedRequests.toLocaleString();

            var totalNumberOfRequests = api.column( 12, {filter:'applied'} ).data().sum();
            var totalNumberOfRequestsPrettified = totalNumberOfRequests.toLocaleString();

            var columnPercentage = percentage(totalNumberOfFailedRequests, totalNumberOfRequests);

            $("#totalNumberOfFailedRequests").text(
                totalNumberOfFailedRequestsPrettified
            );

            $("#totalNumberOfRequests").text(
                totalNumberOfRequestsPrettified
            );

            $("#columnPercentage").text(
                columnPercentage
            );

        }

    });

    function percentage(partialValue, totalValue) {
        var percent = (100 * partialValue) / totalValue;
        return percent.toFixed(3);
    } 


});

Replies

Sign In or Register to comment.