SoFunction
Updated on 2025-02-28

When rendering data tables in the layui problem, only 10 data pieces appear

1. Problem

After ajax obtains server data, it needs to render the table dynamically, but only 10 pieces of data are displayed, and all the data is not rendered.

2. Pass

Take a look at the data required in the table. There is a key-value pair named LAY_TABLE_INDEX for 0-9 pieces of data, but none of the 10 pieces and subsequent data does not have this key-value pair.

I'm very puzzled. This table does not have a paging function, so there should be no need to write limit to limit the data.

({
    elem: '#orderTable'
    ,height: 400
    ,cols: [[ //Title bar     {field: 'status', title: "Order Status", width: 90}
     ,{field: 'orderSerialNumber', title: "Order number", minWidth: 150}
     ,{field: 'logisticsSerialNumber', title: "Logistics serial number", minWidth: 150}
     ,{field: 'curPos', title: "Current Location", minWidth: 150}
     ,{field: 'monitoringState', title: "Monitoring status", width: 140}
     ,{field: 'lastUpdated', title: "Update time", width: 145, sort: true}
     ,{field: 'operating', title: "operate", minWidth: 220}
    ]]
    ,data: handleData
    ,even: true
   });

3. Results

I saw the official website that the limit parameter (default: 10) is consistent with the number of data strips limited by your server. Just add limit, and it is the same as the number of data on the server.

({
    elem: '#orderTable'
    ,height: 400
    ,cols: [[ //Title bar     {field: 'status', title: "Order Status", width: 90}
     ,{field: 'orderSerialNumber', title: "Order number", minWidth: 150}
     ,{field: 'logisticsSerialNumber', title: "Logistics serial number", minWidth: 150}
     ,{field: 'curPos', title: "Current Location", minWidth: 150}
     ,{field: 'monitoringState', title: "Monitoring status", width: 140}
     ,{field: 'lastUpdated', title: "Update time", width: 145, sort: true}
     ,{field: 'operating', title: "operate", minWidth: 220}
    ]]
    ,data: handleData
    ,even: true
    ,limit: limit //The number of displayed   });

Note: handleData is the data required by the table when rendering a table.

When rendering the data table in the above layui problem, the solution to only 10 pieces of data appears is the entire content I share with you. I hope you can give you a reference and I hope you can support me more.