我使用ajax调用从服务器获取数据,然后使用fnAddData将其添加到我的数据表中,它显示数据就好了,问题是当我在搜索框上键入任何内容时,表格中没有显示匹配的行。我想这与fnAddData有关吗?
这是我的代码:
$oTbl = $('#tbl').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
$.ajax({
url: "Fn.php",
type: "POST",
data: {fn: "readData"},
cache: false,
success: function (res) {
$oTbl.fnClearTable();
$oTbl.fnAddData(JSON.parse(res));
}
});
$oTbl = $('#tbl').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
$.ajax({
url: "Fn.php",
type: "POST",
data: {fn: "readData"},
cache: false,
success: function (res) {
$oTbl.fnClearTable();
$oTbl.fnAddData(JSON.parse(res));
}
});
答案 0 :(得分:0)
Json Example: {readData:[{"id":1,"name":"clearing House"}]
dTable = $('#tbl').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"sAjaxSource": "Fn.php", //your url
"sAjaxDataProp": "readData", //your json obj
"aoColumns": [
{ "mDataProp": "id", "bVisible":false },
{ "sTitle":"Provider Name", "mDataProp": "name" }
]
});
Hope this helps u...