您的位置:首页 > 其它

Ext4使用总结(十一) Grid的单元格的背景色和字体的处理

2016-12-19 17:43 447 查看
1    修改表格的单元的背景色

       1.1 在html文件中,增加单元格的样式定义

<style>
.x-grid-cell.yellow_cell{background-color: yellow}
.x-grid-cell.red_cell{background-color: red}
</style>

1.2  Grid的单元格定义中增加renderer函数,使用样式

{
    xtype: 'gridcolumn',
    dataIndex: 'fieldname',
    text: '字段名称',
renderer: function (value, metadata, record, rowIndex,  colIndex, store) {
if (value == null || value == undefined) return value;
if (eval(value) < eval(0)) {
metadata.tdCls = 'red_cell';
}
if (eval(0) <= eval(value) && eval(value) < eval(1000)) {
metadata.tdCls = 'yellow_cell';
}
return value;
}
}

2  不同颜色显示单元格中的字
在表格的字段的定义中增加renderer函数
renderer: function (value,metadata, record, rowIndex, colIndex,store) {
     return  '<div style="font-weight:bold;color:red">'+ value + '</div>';
}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐