JQuery EasyUI DataGrid根據條件設置表格行樣式(背景色)


1.javascript定義函數返回樣式

<script type="text/javascript">
    //根據條件設置表格行背景顏色
    function setRowBgColor(index, row) {
        if (row.ERROR_INFO != null && row.ERROR_INFO != "") {
            return 'background-color:yellow;color:black;';
        }
    }
</script>

2.在table的屬性中設置rowStyler對應的function為之前定義的setRowBgColor

<table id="gridFileImport" class="easyui-datagrid" style="width:780px;height:420px;" data-options="rownumbers:true,singleSelect:true,selectOnCheck:false,checkOnSelect:false,pagination:true,pageSize:20,url:'',method:'get',striped:true,rowStyler:setRowBgColor">

PS:DataGrid自帶的表格隔行變色屬性設置striped:true

3.效果圖如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM