我有2列带有日期,并且想要验证包含内容的记录是否具有并行记录,这是一个示例:
-------------------
Open |
-------------------
Open | Hello
-------------------
Closed | Closed
-------------------
Processed|
------------------
具有OPEN值的记录不应包含任何文本(在此情况下为单词:hello),因为必须应用此类。
到目前为止,这是我的代码,非常感谢!
"rowCallback": function (row, data, index) {
if (data[1] === 'Open' && data[2].length > 0) {
$(row).addClass('selected');
}
}
答案 0 :(得分:0)
这是一个工作的小提琴。 http://jsfiddle.net/bbLjzspf/7426/
$(document).ready(function() {
var dataSet = [
["1", "Open", ""],
["2", "Open", "Hello"],
["3", "Closed", "Closed"],
["4", "Processed", ""],
];
var columnDefs = [{
title: "id"
}, {
title: "status"
}, {
title: "whatever"
}];
var myTable;
myTable = $('#example').DataTable({
"rowCallback": function(row, data) {
if (data[1] == "Open" && data[2].length > 0) {
console.log(data[2]);
$(row).addClass('selected');
}
},
"sPaginationType": "full_numbers",
data: dataSet,
columns: columnDefs,
dom: 'Bfrtip', // Needs button container
select: 'single',
responsive: true,
altEditor: true, // Enable altEditor
buttons: [{
text: 'Add',
name: 'add' // do not change name
},
{
extend: 'selected', // Bind to Selected row
text: 'Edit',
name: 'edit' // do not change name
},
{
extend: 'selected', // Bind to Selected row
text: 'Delete',
name: 'delete' // do not change name
}
]
});
});