JQuery DataTables改变行或列的背景或字体颜色
JQuery DataTables改变行或列的背景或字体颜色
var table;
table = $('#example').DataTable({
dom: 'Bfrtip',
scrollY: true,
scrollX: true,
scrollCollapse: true,
colReorder: true,
select: true,
stateSave: true,
//info: false,//关闭左下角关于行数和选中的提示
//filter: false,//关闭搜索
//paging: false,//关闭分页
pagingType: "full_numbers",
columns: [
{ title: "Name", data: "Name", className: "center" },
{ title: "Position", data: "Position" },
{ title: "Office", data: "Office" },
{ title: "Age", data: "Age" },
{ title: "Salary", data: "Salary", className: "canEditor" },
{ title: "操作", data: null, defaultContent: "<button type='button'>编辑</button>" }
],
rowCallback: RowCallBack,
language: {
url: dtsLanguage
}
});
function RowCallBack(row, data, index) {
if (data.Name.indexOf('Tiger') >= 0) { $(row).css('background-color', '#FFB6C1'); }//行变色
$('td', row).eq(5).css('font-weight', "bold").css("color", "red");//列变色
}