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.效果圖如下: