当某些值不是"错误"时,我会尝试隐藏表格中的按钮。
它在第一页上完美运行,但由于分页,按钮不会隐藏在第二页上。
$(function() {
$('#table1').each(function() {
var Cell = $(this).find('td:eq(2)');
debugger;
if (Cell.text() !== 'error' ) {
$(this).find('button').hide();
}
});
});
答案 0 :(得分:1)
就像您使用initComplete
回调一样,您可以通过DataTable选项传递drawCallback
函数。这将在每次绘制表时运行。只需将以下内容添加到选项中即可。
请参阅:https://datatables.net/reference/option/drawCallback
drawCallback: function (settings) {
$('#table1').each(function () {
var Cell = $(this).find('td:eq(2)');
debugger;
if (Cell.text() !== 'error') {
$(this).find('button').hide();
}
});
}
答案 1 :(得分:0)
您必须在页面更改时调用该函数。如果检查表,则可以看到未加载的所有行。