Columanfilter在服务器端预处理的数据表中不起作用。具有列搜索的数据表不起作用。下面的代码是示例代码。请在jsdiddle或任何其他文件中提供。请帮帮我。这是javascript代码
$(document).ready(function() {
drawDataTable = function()
{
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "../server_side/scripts/server_processing.php",
"sPagination": "full_numbers",
"bFilter": true,
"oSearch":{
"sSearch":"",
"bRegex": false,
"bSmart": true },
"aoColumns":[
{"bSearchable": true},
null,
null,
null
]
})
.columnFilter({
aoColumns: [{
type: "text"
}, {
type: "text"
}, {
type: "text"
},{
type: "text"
}]
});
}
drawDataTable();
} );
这是Html代码
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
</tr>
</tfoot>
</table>
看起来你的身体在thead
和tfoot
:之间
<tbody>
<tr>
<td>Name</td>
<td>Position</td>
<td>Office</td>
<td>Extn.</td>
</tr>
</tbody>
似乎没有正确传递sSource值。sSource基本上是DataTables.js中的"ajax"url值。我的解决方案是从columnFilter.js文件第796行的DataTable ajax值中重新添加sSource:
sSource = sSource ? sSource : oTable.fnSettings().ajax;
所以它看起来像:
oTable.fnSettings().fnServerData = function (sSource, aoData, fnCallback) {
sSource = sSource ? sSource : oTable.fnSettings().ajax;
....
}