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