【问题标题】:DataTables warning: table id=big_table - Requested unknown parameter '0' for row 0.DataTables 警告:表 id=big_table - 为第 0 行请求未知参数“0”。
【发布时间】:2014-09-07 11:03:03
【问题描述】:

我正在使用 jquery 数据表插件和 codeigniter,同时尝试(大致)关注http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/。我收到以下错误:

DataTables warning: table id=big_table - Requested unknown parameter '0' for row 0. For more information about this error, please see http://datatables.net/tn/4

在 firebug 中没有错误并且返回以下 JSON:

{"draw":0,"recordsTotal":3,"recordsFiltered":3,"data":[{"id":"2","message_id":"<047d7bf1665e40753c04fd394d72@google.com>","subject":"Delivery Status Notification (Failure)","date":"2014-07-02 19:34:17"},{"id":"3","message_id":"<ad86a2fb8673b8a6.14044068.406744.354605.en-US.b5df177c74ea@google.com>","subject":"Flying the red, white and blue on YouTube","date":"2014-07-03 19:01:21"},{"id":"4","message_id":"<047d7bf1665e04fd640c89@google.com>","subject":"Delivery Status Notification (Failure)","date":"2014-07-04 22:34:16"

我注意到即使记录数 (3) 是正确的,平局也是 0。表本身是空的。

我该如何解决这个问题?

我的控制器:

函数索引() {

        //set table id in table open tag
        $tmpl = array('table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">');
        $this->table->set_template($tmpl);


        $this->table->set_heading("id,message_id,subject,date");

        $this->load->view('serversidetestview');
    }

    //function to handle callbacks

    function datatable()
    {

        $this->datatables->select("id,message_id,subject,date")->from('imap');
        echo $this->datatables->generate();
    }    

我的看法:

<html> 
  <head> 
      <base href="<?=base_url();?>">

       <!-- DataTables CSS -->

    <link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.1/css/jquery.dataTables.css">

    <!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>

<!-- DataTables -->

<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.1/js/jquery.dataTables.min.js"></script>    



  </head> 
  <body> 


<h1>Subscriber management</h1>
<?php echo $this->table->generate(); ?>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var oTable = $('#big_table').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": 'datatable_controller/datatable',
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "iDisplayStart ": 20,

            "fnInitComplete": function () {
                oTable.fnAdjustColumnSizing();
            },
            'fnServerData': function (sSource, aoData, fnCallback) {
                $.ajax
                ({
                    'dataType': 'json',
                    'type': 'POST',
                    'url': sSource,
                    'data': aoData,
                    'success': fnCallback
                });
            }
        });
    });
</script>

  </body> 
</html> 

【问题讨论】:

    标签: php jquery codeigniter datatables


    【解决方案1】:

    从示例代码的库中复制 Datatables.php (http://www.ahmed-samy.com/demos/sources/tutorial_datatables.zip) 进入您的库目录,而不是直接下载它。我认为最新下载中可能存在错误。我遇到了完全相同的问题。

    【讨论】:

    • 您好,感谢您的回答,但我很困惑:哪个版本是正确的?
    • 对不起。对我有用的 Datatables.php 是 zip 教程 zip 文件中的那个。我直接从网站下载的那个好像不行。
    • 谢谢,是的,我刚试过,zip 文件中的 0.7 版也适用于我
    猜你喜欢
    • 2019-01-25
    • 1970-01-01
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多