我在codeigniter应用程序中使用Ignited Datatables。除搜索和排序外,一切正常。我的代码是这样的: 控制器页面:
public function datatable()
{
$this->datatables->select("
insight_project.projectName projectName,
insight_project_module.moduleName moduleName,
insight_project_submodule.subModuleName issueName,
insight_project_submodule.estimatedTime estimatedTime,
insight_worksheet.spentTime,
insight_activity_list.name activityName,
insight_status.name statusName,
insight_worksheet.completedPercentage,
insight_worksheet.updatedById,
insight_worksheet.activity worksheetFillUpDate,
insight_worksheet.projectId workingDate,
insight_worksheet.reason,
insight_worksheet.worksheet_status
")
->from("insight_worksheet")
->join("insight_project_module","project_module.id=worksheet.moduleId","left")
->join("insight_project","project.id=worksheet.projectId","left")
->join("insight_project_submodule","project_submodule.id=worksheet.submoduleId","left")
->join("insight_activity_list","activity_list.id=worksheet.activity","left")
->join("insight_status","status.id=worksheet.status","left");
echo $this->datatables->generate();
}
并在视图页面中存在与datatables插件相关的代码。 我已经包含了jquery库文件和jquery.dataTables.min.js。
<script type="text/javascript">
$(document).ready(function () {
var oTable = $('#big_table').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '<?php echo site_url() ?>/worksheet/datatable',
"sDom": '<"H"Tlpf>rt<"F"ip>',
"aoColumns": [
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true},
{"bSearchable": true,"bSortable": true}
],
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ": 20,
"oLanguage": {
"sProcessing":
"<img
src='<?php echo base_url(); ?>Assets/images/ajax-loader_dark.gif'
alt='processing_srimanta'>"
},
"fnInitComplete": function () {
// oTable.fnAdjustColumnSizing();
},
'fnServerData': function (sSource, aoData, fnCallback) {
aoData.push({
name: '<?php echo $this->security->get_csrf_token_name(); ?>',
value: '<?php echo $this->security->get_csrf_hash(); ?>'});
$.ajax
({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success': fnCallback
});
}
});
});
</script>
<?php echo $this->table->generate(); ?>
但搜索和列排序不起作用。 请让我知道我的问题是什么。 提前谢谢。