又是我,我需要你最大的帮助:)
我正在写我的论文,有很多工作要做,我确实搜索了很多,但我仍然没有找到我问题的正确答案,所以我在这里。
无论如何,我正在使用Codeigniter和Ignited Datatables来显示我的记录。我显示记录没有问题,但搜索和记录限制不起作用。我遵循了本教程:http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/它的搜索正在工作,我们得到了几乎相同的代码。
这是我的:
脚本:
$(document).ready(function(){
var oTable = $('#clientDT').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'http://localhost:81/ORPS/client/viewClientsJSON',
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ": 10,
"oLanguage": {
"sProcessing": "<img src='http://localhost:81/ORPS/images/loading-icons/loading3.gif'>"
},
"fnInitComplete": function() {
//oTable.fnAdjustColumnSizing();
},
'fnServerData': function(sSource, aoData, fnCallback)
{
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
},
} );
});
这是我的控制器:
function viewClientsJSON(){
$clientList = $this->clientmodel->clientDT();
return $clientList;
}
这是我的模型:
function clientDT(){
$this->datatables->select('PersonId, LastName, FirstName, MiddleName')
->where('PersonTypeId', '1')
->where('IsActive', '1')
->add_column('Action', get_buttons('client/viewClient/$1', 'client/editClient/$1', '$1'), 'PersonId')
->from('person');
echo $this->datatables->generate();
}
我的观点是:
<div class="table-responsive addMarginTop">
<table id="clientDT" class="table table-condensed table-striped table-hover">
<thead>
<tr>
<th>ID</th>
<th>Last Name</th>
<th>First Name</th>
<th>Middle Name</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
非常感谢你一直帮助我。 :)
您使用的数据表版本是什么?如果您使用的是最新版本1.10,请注意有很多更改。
请参阅链接数据表 - 升级 1.10。除此之外,我认为应该没有任何问题。
如果您仍然面临,请尝试使用Chrome或Firefox的开发人员工具,并查看Conole选项卡以获取可能有助于深入挖掘的可能错误。