php - 如何增加 jquery DataTable 显示的条目数?

标签 php jquery phpmyadmin datatables

我有一个包含 18000 行的数据库。 DataTable 显示前 500 行。

如何增加它可以显示的条目数量?

pageLengthlengthMenu 属性不会影响结果。

game_db.php

<?php
function getGames() { 
    $query = "select * FROM games LIMIT 10000"; 
    try {
    global $db;
        $games = $db->query($query);  
        $game = $games->fetchAll(PDO::FETCH_ASSOC);
        header("Content-Type: application/json", true);
        echo '{"games": ' . json_encode($game) . '}';
    } catch(PDOException $e) {
        echo '{"error":{"text":'. $e->getMessage() .'}}'; 
    }
}
?>

ma​​in.js

function renderList(data){
    list = data.games;
    console.log("renderList");
    $('#admin_table_body tr').remove();
    $.each(list, function(index, games){
        $('#admin_table_body').append('<tr><td>' +games.title+'</td><td>'+games.genre+'</td><td>' 
                +games.platform+'</td><td>' +games.score_phrase+'</td><td>'
                +games.score+'</td><td>'+games.release_year+'</td><td>'+games.release_month+'</td><td>'
                +games.release_day+'</td><td>'+games.editors_choice+'</td><td>\n\
                <a href="#"  id="'+games.id+'" "span class="fa fa-pencil" data-toggle="modal" data-target="#editModal">Edit</a></td></tr>');
    });
    $('#admin_table').DataTable();

这会生成数据表中的行。

最佳答案

使用 iDisplayLength 参数

$(document).ready( function() {
  $('#example').dataTable( {
    "iDisplayLength": 1000 // to display 1000 rows
    "iDisplayLength": -1 // to display all rows
  } );
} )

https://legacy.datatables.net/ref#iDisplayLength

关于php - 如何增加 jquery DataTable 显示的条目数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47601185/

相关文章:

database - Magento 安装停留在配置

jquery - 回发期间的动画模拟更平滑的页面重定向

javascript - JQuery 和 PHP : How to pass appended button value to jquery? 有可能吗?

php - 从旧的 mysql 文件夹中获取旧的 MySQL 数据并导入到新数据库中

php - Zend Framework 中数据库驱动路由的教程?

javascript - 如何使用 jQuery 检查 HTML 内容中的文本?

mysql - [ docker ] : Connecting PHPMyAdmin to MySQL doesnt work

javascript - PHP/Ajax : How to show/hide DIV on $_SESSION variable value?

php - Laravel 5.1 使用 ajax 调用在数据库中保存一些东西

javascript - 如何将 SVG 图像转换为标准图像格式(例如 PNG 或 JPEG)?