您好我在尝试显示数据库中的数据时遇到问题,我可以在数据库中显示表格中的每个数据但是当我尝试在表格中显示所有数据时,它会在标题中显示错误,我不会#39;不知道为什么。我使用的是codeigniter。
这是控制器功能
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个数据。
我显示的数据有整数和字符串。
数据表版本为0.7
答案 0 :(得分: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();
}
我不知道为什么选择必须像这样而不是注释的。但它修复了表并正确显示它。