描述
某個表的數據是用JQuery的JTable插件進行展示的。現在需求是:當表中的master字段為true時,就將對應的整行的背景顏色設置為淺藍色。
處理方法
在fields:{},后面添加:
rowInserted: function (event, data) { //若是當前主節點,整行顯示不一樣的顏色(淺藍色)
if (data.record) {
if (data.record.master == true) {
data.row.css("background", "#C0D9D9");
}
/* if (data.record.master == true) {
$('#PersonTableContainer').find(".jtable tbody tr td:eq(2)").css("background", "#F5ECCE");
} */
}
}
參考
https://github.com/hikalkan/jtable/issues/1427#issuecomment-50030798
https://stackoverflow.com/questions/19486519/how-can-i-change-the-background-color-in-a-specific-row-of-jquery-jtable