W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
本節(jié)中的示例將根據(jù)不同的設(shè)置條件來對jQuery EasyUI數(shù)據(jù)網(wǎng)格(datagrid)中行的樣式進行更改。當將listprice的值設(shè)置為大于50時,我們將為該行設(shè)置不同的顏色。
數(shù)據(jù)網(wǎng)格的rowStyler函數(shù)的設(shè)計目的是允許您自定義行樣式。以下代碼展示如何改變行樣式:
<table id="tt" title="DataGrid" style="width:600px;height:250px" url="data/datagrid_data.json" singleSelect="true" fitColumns="true">
<thead>
<tr>
<th field="itemid" width="80">Item ID</th>
<th field="productid" width="80">Product ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right">Unit Cost</th>
<th field="attr1" width="150">Attribute</th>
<th field="status" width="60" align="center">Stauts</th>
</tr>
</thead>
</table>
$('#tt').datagrid({
rowStyler:function(index,row){
if (row.listprice>50){
return 'background-color:pink;color:blue;font-weight:bold;';
}
}
});
正如您所看到的,我們根據(jù)一些條件設(shè)置background-color(背景色)為pink(粉紅色),設(shè)置文本顏色為blue(藍色)。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: