Datatables JS使用延迟渲染缓慢渲染

时间:2015-11-05 21:17:36

标签: php jquery mysql datatables

我正在尝试加载大约2,000条记录,渲染时间差不多需要一分钟。我看到记录立即显示但是然后需要一段时间才能加载为分页。我有延迟渲染选项,但我不知道它们是否正在工作。

我的初学者:

table.dataTable({
    "language": {
            "aria": {
                "sortAscending": ": activate to sort column ascending",
                "sortDescending": ": activate to sort column descending"
            },
            "emptyTable": "No data available in table",
            "info": "Showing1 _START_ to _END_ of _TOTAL_ entries1",
            "infoEmpty": "No entries found",
            "infoFiltered": "(filtered1 from _MAX_ total entries)",
            "lengthMenu": "Show _MENU_ entries",
            "search": "Search:",
            "zeroRecords": "No matching records found"
        },
        "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
        "bProcessing": true,
        "bDeferRender": true,
        "deferRender": true,
        "orderClasses": false,


 ......

我正在使用DataTables版本1.10.2

我的php循环:

$users=user::get_all($filter);
        if($users){
          foreach($users as $row){
            $customer=user::get_cutomer_name_by_source_id($row['source_id']);
            ?>
            <tr class='odd gradeX'>
              <td><input type='checkbox' class='checkboxes' value='1'/></td>
              <td><?php echo $row['first_name']." ".$row['last_name']; ?></td>
              <td><?php echo $row['source_id']; ?></td>
              <td><?php echo $row['email']; ?></td>
              <td><?php echo $customer; ?></td>
              <td><?php echo date("m/d/Y", strtotime($row["created"])); ?></td>
              <td><?php if($row['login']!=NULL){echo date("m/d/Y",$row['login']);} ?></td>
              <td><?php if($row['active']==1){echo "Yes";}else{echo "No";} ?></td>
              <td><?php echo user::get_role_name($row['rid']); ?></td>
              <td><?php 
                if($row['cash_incentive']==1){echo "Cash";}else{echo "Regular";} ?>
                </td>
              <td><a href='user-edit?uid="<?php echo $row['uid']; ?>"'>View </a></td>
              <td><a href='switch?email=<?php echo $row['email']; ?>'> Switch</a></td>
              <td><input type='checkbox' name='email-list[]' value='<?php echo $row['email']; ?>'></td>
            </tr>   
          <?php }
        }

user :: get_all函数:

public static function get_all($filter=NULL,$limit=NULL){
    global $db;     
    $db->SelectRows("users",$filter, NULL, NULL, TRUE,$limit);
    return $db->RecordsArray(MYSQL_ASSOC);
}

0 个答案:

没有答案