1
我使用IgnitedDatatables(CodeIgniter庫)DataTables。該表生成沒有問題,但如果我搜索/過濾它一次只能過濾一列。如果我將「bServerSide」設置爲false,它可以工作,但是我失去了服務器端的功能。DataTables:當服務器端搜索所有列
在這些例子中,這一項工作: http://datatables.net/release-datatables/examples/ajax/custom_data_property.html
雖然這不是(服務器端): http://datatables.net/release-datatables/examples/data_sources/server_side.html
這是不可能的運行服務器端的時候實現?
這是我的JSON響應(縮短了,取而代之的數據):
{"sEcho":0,"iTotalRecords":45438,"iTotalDisplayRecords":45438,"aaData":[["abc","12345","[email protected]","","","2010-01-27 22:31:10","Edit<\/a> Delete<\/a>"],["abc2"," test123","[email protected]","","","2008-06-15 22:09:33","Edit<\/a> Delete<\/a>"]],"sColumns":"fname,lname,email,phone,cellphone,created,edit"}
JavaScript代碼:
$("#members").dataTable({
"bProcessing": true,
"bServerSide": true,
'sAjaxSource': '<?php echo base_url();?>members/listener',
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": 'POST',
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"bLengthChange": false,
"aaSorting": [[ 0, "asc" ]],
"iDisplayLength": 15,
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"aoColumnDefs": [
{ "sName": "fname", "aTargets": [ 0 ] },
{ "sName": "lname", "aTargets": [ 1 ] },
{ "sName": "email", "aTargets": [ 2 ] },
{ "sName": "phone", "sWidth": "80px", "aTargets": [ 3 ] },
{ "sName": "cellphone", "sWidth": "100px", "aTargets": [ 4 ] },
{ "sName": "created", "sWidth": "120px", "aTargets": [ 5 ] },
{ "bSortable": false, "sName": "edit", "sWidth": "115px", "aTargets": [ 6 ] }
]
});
謝謝!