简体   繁体   中英

Datatables doesn't recognize pageLength for number of rows

I'm simply trying to have only 15 rows when I bring my data up. For some reason it is not working. Any help would be appreciated.

    $('.datatable').dataTable({
    "processing": true,
    "serverSide": true,
    "ajax": {
        "url": "/ajaxI/gd/1/54",
        "data": function (d) {

        }
    },
    "paging": true,
    "searching": false,
    "lengthChange": true,
    "lengthMenu": [[15, 25, 50, -1], [15, 25, 50, "All"]],
    "pageLength": 15,
    "oLanguage": {
        "sProcessing": ' &nbsp; <img src="/img/ajax-loader-large.gif" alt="Loading" width="26" height="26" />'
    },
    "autoWidth" : false        }
});

All my data shows up for some weird reason.

On the table element, use:

data-page-length='15' eg

<table id="table" class="" data-page-length='15' >

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