javascript - 在 ExtJS 中使用函数

标签 javascript extjs

我是 ext-js 的新手。

我有一个容器网格,我需要做的是:如果一行中 2 列之间的差异大于 2,则该行应为红色。

我不知道该怎么做。

columns: [
                                            {
                                                xtype: 'gridcolumn',
                                                dataIndex: 'val_1',
                                                text: 'val_1'
                                            },
                                            {
                                                xtype: 'gridcolumn',
                                                dataIndex: 'val_2',
                                                text: 'val_2'
                                            }

最佳答案

试试这个例子

Ext.onReady(函数(){

var store = Ext.create('Ext.data.ArrayStore', {

字段:['价格', '变化'],

数据:[

[0, 0],

[2, 3],

[0, 1],

[2, 3],

[5, 6],

[0,0]

]

});

var grid = Ext.create('Ext.grid.Panel', {

title: '阵列网格',

商店:商店,

列:[

{text: 'Price', width: 75, dataIndex: 'price'},

{text: 'Change', width: 75, dataIndex: 'change'}

],

View 配置:{

stripeRows: false,

getRowClass: function(record) { 

    return record.get('price')+record.get('change') > 2 ? 'change-row-color':'';  

    } 

}, 

高度:200,

宽度:200,

渲染到:Ext.getBody()

});

});

CSS:

.change-row-color .x-grid-cell {

背景颜色:#ffe2e2;

颜色:#900;

关于javascript - 在 ExtJS 中使用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17992537/

相关文章:

javascript - 在index.html 中使用编译的JavaScript 代码应该是正确的做法吗?

javascript - 使用 React 删除 Firebase 中的项目,重新渲染返回项目未定义

javascript - 如何提高 jQuery 的性能

javascript - Express JS Node JS multer 集成问题

extjs - 在 Ext.window 中淡入/淡出

html - CSS - 已声明样式的计算样式

extjs - 如何在json-store中添加记录

javascript - Ext.form.NumberField 中的千位分隔符

javascript - JQuery ajax 成功时未捕获 TypeError

javascript - Nightmare.js 屏幕截图缓冲区长度为 0