如何根据Datatables中的单元格值禁用行复选框。有一些表和列具有类似System的数据。如果是,系统需要取消该行的销售。尝试使用以下代码,复选框未被禁用。
this.dtOptions = {
ajax: 'assets/test.json',
initComplete: function (settings, json) {
$.each(json.data, function (index, value) {
if(value.matchType == "System"){ //working
$("table").closest('tbody tr td').find('input:checkbox').prop('disabled', true);
}
});
},
I你的代码,如果index是你的行索引,那么你可以尝试这个
this.dtOptions = {
ajax: 'assets/test.json',
initComplete: function (settings, json) {
$.each(json.data, function (index, value) {
if(value.matchType == "System"){ //working
$("table tr").eq(index).find('input:checkbox').prop('disabled', true);
}
});
},
@Yuvraj的回应启发了我以下的解决方案;createdRow";事件
'createdRow': function (row, data, dataIndex) {
if (!data.isAvailable /* some condition based on data */) {
$(row).find('input:checkbox').prop('disabled', true);
}
}