删除行后,序列号列号不重新排序。
我在每一行中都有Delete按钮,点击调用Ajax从数据中删除记录。它正在从数据库中删除记录,在删除记录之后,我希望显示保留数据并删除表中的特定行,但它正在更改分页和刷新整个表。
var owner_table = null;
$(document).ready(function () {
owner_table = $('#owners_table').DataTable();
});
function deletehouseowner(oid, rid) {
$.ajax({
dataType: "HTML",
type: "POST",
data: {
"oid": oid
},
url: "houseowner_delete.php",
success: function (msg) {
if (msg === "failure") {
} else {
event.preventDefault();
var table = 'owners_table';
var row = $(this).closest('tr');
var id = row.attr("id");
setTimeout(function () {
var siblings = row.siblings();
owner_table.row($('#row_' + rid)).remove().draw();
siblings.each(function (index) {
$(this).children().first().text(index + 1);
});
}, 100);
}
}
});
}
截图:
发布于 2015-10-22 15:31:08
溶液
API方法draw()
接受可选参数,该参数控制表应该如何更新。
将false
传递到draw()
函数以保留当前页面,请参见下面的代码:
owner_table.row($('#row_'+rid)).remove().draw(false);
演示
有关代码和演示,请参见这个jsFiddle。
https://stackoverflow.com/questions/33284617
复制相似问题