【发布时间】:2015-11-06 04:11:49
【问题描述】:
我在 ExtJS 中有一个 PropertyEditor。
Ext.define('PropertyEditorGrid', {
//...
this.flexColumnGrid = Ext.create('Ext.grid.property.Grid', {//...
listeners:{
propertychange: function (source, recordId, value,oldValue,eOpts){
me.valueChange(me.id,recordId,value==null?null:value.toString(), oldValue==null?null:oldValue.toString());
}
}//...
}
我想使用 'propertychange' 功能,如果值不合适,则以红色打印网格单元格文本,否则以黑色打印。我尝试使用http://skirtlesden.com/articles/styling-extjs-grid-cells,但它对我没有帮助。
【问题讨论】:
-
使用 afteredit 获取列 el add css to it
-
我添加了以下函数:edit: function(editor, e) { e.grid.cls = 'x-grid-wrong-value'; console.log('afteredit'); } 在 css 中: .x-grid-wrong-value{color: #f00} 我看到日志消息,但文本不是红色
-
从 e 中获取 td el。它将在 e.column 中添加类或使用 validateEdit 侦听器
-
我添加了类:edit : function(editor, e) { console.log(e.column.el); e.column.el.addCls('x-grid-wrong-value'); } 但它不起作用
-
试试这个解决方案它会帮助你jsfiddle.net/w8wjmj4L/2
标签: javascript string extjs colors