更新时间:2023-02-05 18:20:43
看起来你可以使用 API 函数来
It looks as if you could use the API functions to
更新
我猜您正在使用 DOM 数据源(用于服务器端处理)生成您的表格.一开始我并没有真正理解这一点,所以我之前的答案对此不起作用.
I guess you're using the DOM Data Source (for server-side processing) to generate your table. I didn't really get that at first, so my previous answer won't work for that.
在不重写服务器端代码的情况下使其工作:
To get it to work without rewriting your server side code:
您需要做的是完全删除旧表(在 dom 中)并将其替换为 ajax 结果内容,然后重新初始化数据表:
What you'll need to do is totally remove the old table (in the dom) and replace it with the ajax result content, then reinitialize the datatable:
// in your $.post callback:
function (data) {
// remove the old table
$("#ajaxresponse").children().remove();
// replace with the new table
$("#ajaxresponse").html(data);
// reinitialize the datatable
$('#rankings').dataTable( {
"sDom":'t<"bottom"filp><"clear">',
"bAutoWidth": false,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "bSortable": false, "sWidth": "10px" },
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
}
);
}