DataTables警告:表id=big_table——请求第0行的未知参数“0”。

时间:2022-10-07 15:43:48

DataTables警告:表id=big_table——请求第0行的未知参数“0”。

I'm working with the jquery datatables plugin and codeigniter , while trying to follow (roughly ) http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/. I am getting the following error:

我正在使用jquery datatables插件和codeigniter,同时尝试遵循(大致上)http://www.ahmed-samy.com/php-codeigniter- jquery-datatabl -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

In firebug there are no errors and the following JSON is returned:

在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"

i notice that the draw is 0 even though the number of records (3) is correct. The table itself its empty.

我注意到,即使记录(3)的数目是正确的,但平局还是0。桌子本身是空的。

How can I fix this?

我怎么解决这个问题?

My controller:

我的控制器:

function index() {

函数索引(){

        //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();
    }    

My view:

我的观点:

<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> 

1 个解决方案

#1


1  

Copy the Datatables.php from the libraries of the sample code (http://www.ahmed-samy.com/demos/sources/tutorial_datatables.zip) into your libraries directory instead of downloading it directly. I think there might be a bug in the latest download. I had the exact same issue.

datatable副本。从样例代码库(http://www.ahmed-samy.com/demos/sources/tutorial_datatables.zip)到您的库目录,而不是直接下载。我想在最新的下载中可能会有一个bug。我也有同样的问题。

#1


1  

Copy the Datatables.php from the libraries of the sample code (http://www.ahmed-samy.com/demos/sources/tutorial_datatables.zip) into your libraries directory instead of downloading it directly. I think there might be a bug in the latest download. I had the exact same issue.

datatable副本。从样例代码库(http://www.ahmed-samy.com/demos/sources/tutorial_datatables.zip)到您的库目录,而不是直接下载。我想在最新的下载中可能会有一个bug。我也有同样的问题。