2016-10-14 127 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。但它修復了表格並正確顯示。

相關問題