2016-10-14 75 views
0

你好我有问题试图显示来自我的数据库的数据,我可以从我的数据库中的表中显示每个数据,但是当我尝试在表中显示所有数据时它在标题中给出错误,我不知道为什么。我正在使用codeigniter。Datatable请求来自数据源行0的未知参数'2'

这是控制器功能

public function datatable() 
{ 

    $this->datatables->select('name', 'user_id', 'last_name','identify','contact','rol_type')  
     ->unset_column('user_id') 
     ->add_column('actions', get_buttons('$1','users'),'user_id') 
     ->from('users') 
     ->where(array('user_status'=>'1')); 

    echo $this->datatables->generate(); 

} 

USER_ID是自动增量的变量。

这是查看页面。

<?php 
//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('Name','Last Name','Identify Card','Contact Number','Rol assign,'Actions'); 
    echo $this->table->generate(); 
?> 
<script type="text/javascript"> 

    $(document).ready(function() {    

    var oTable = $('#big_table').dataTable({ 
     "bProcessing": true, 
     "bServerSide": true, 
     "sAjaxSource": '<?php echo base_url(); ?>users/datatable', 
       "bJQueryUI": true, 
       "sPaginationType": "full_numbers", 
       "iDisplayStart ":20, 
       "oLanguage": { 
        "sUrl":'<?php echo base_url(); ?>users/translate' 
     }, 
       "fnInitComplete": function() { 
       //oTable.fnAdjustColumnSizing(); 
        }, 
       'fnServerData': function(sSource, aoData, fnCallback) 
        { 
         $.ajax 
         ({ 
          'dataType': 'json', 
          'type' : 'POST', 
          'url'  : sSource, 
          'data' : aoData, 
          'success' : fnCallback 
         }); 
        } 
    }); 

}); 

</script> 

我在我的程序中使用其他函数的数据表代码,它工作,甚至显示超过4个选定的数据。

我显示的数据有整数和字符串。

DataTable的版本是0.7

+0

哪个代码库用于您使用的数据表?告诉我们,这可能有助于调试您的问题。 – cssBlaster21895

+0

datatables的版本是0.7 –

+0

datatables 0.7或codeigniter datatables 0.7? – cssBlaster21895

回答

0

公共功能的工作原理如下

public function datatable() 
{ 
    //$this->datatables->select('name', 'user_id', 'last_name','identify','contact','rol_type') 
    $this->datatables->select('name') 
     ->select('last_name') 
     ->select('identify') 
     ->select('contact') 
     ->select('rol_type') 
     //->unset_column('user_id') 
     ->add_column('Actions', get_buttons('$1','users'),'user_id') 
     ->from('users') 
     ->where(array('user_status'=>'1')); 

    echo $this->datatables->generate(); 

} 

我不知道为什么选择必须是这样的,而不是一个comented。但它修复了表格并正确显示。

相关问题