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");//列变色
}

 

posted @ 2020-12-28 08:53  不要摸我的腰  阅读(1448)  评论(0编辑  收藏  举报