这又是我,我需要你的帮助:)
我正在研究我的论文并且还有很多工作要做,而且我做了很多搜索,但我仍然找不到正确的答案,所以我在这里。
无论如何,我使用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>
非常感谢能够一直帮助我。 :)
答案 0 :(得分:0)
您正在使用的DataTables的版本是什么?如果您使用的是1.10的最新版本,请注意有很多变化。
请参阅链接Datatables - Upgrade 1.10。除此之外,我不认为应该有任何问题。
如果您仍然面临,请尝试使用Chrome或Firefox的开发者工具,并查看 Conole 标签,了解可能有助于深入挖掘的错误。