easyui 改變單元格背景顏色


另外一種方法:https://www.cnblogs.com/raitorei/p/9989649.html

easyui的datagrid改變整行顏色:https://www.cnblogs.com/raitorei/p/10641342.html

代碼:

jsp:

<table id="roleList">
        <thead>
          <tr>
              <th data-options="field:'ck',checkbox:true"></th>  
              <th data-options="field:'monitor_item_code',width:70,align:'center'">XXX</th>
              <th data-options="field:'gap_value',width:70,align:'center'">XXX</th>
              <th data-options="field:'remark',width:70,align:'center'">XXX</th>
              <th data-options="field:'alarm_role',width:70,align:'center',formatter:alarmRole">XXX</th>
              <th data-options="field:'flag',width:70,align:'center',formatter:flag,styler:flagColor">狀態</th>
              <th data-options="field:'operate',width:80,align:'center',formatter:formatOper">操作</th>
          </tr>
         </thead>
    </table>

js:

function flagColor(val, row, index) {
    if (val == '1') {
        return 'background:#B9F3B9';
    } else if (val == 0) {
        return 'background:#FFCCCC';
    }
}
function flag(val, row, index) {
    return '<a href="javascript:void(0)" class="start"  onclick="changeFlag(' + index + ',1)"></a><a href="javascript:void(0)" class="stop" onclick="changeFlag(' + index + ',0)"></a>';
}

效果:


免責聲明!

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



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