[英]extjs4 Change action column icon dynamically
I'm using getClass
to render the icon in the action column. 我正在使用
getClass
来呈现动作列中的图标。
{
xtype: 'actioncolumn',
id:'actionColumnGridUsers',
width: 30,
hideable: false,
items: ['->',
{
getClass: function (v, meta, rec)
{
if (rec.get('nameUser') != '') return 'icon-edit';
else return 'icon-add';
}
}
}
And the css code: 和css代码:
.icon-add { background-image: url("../images/add.png"); }
.icon-edit { background-image: url("../images/edit.png"); }
The code seems to be correct, but the icon is not shown. 代码似乎是正确的,但图标未显示。 What I'm missing?
我错过了什么?
I have resolved it like this: 我这样解决了:
{
xtype: 'actioncolumn',
id:'actionColumnGridUsers',
width: 30,
hideable: false,
items:
[{
getClass: function(v, meta, rec) {
if (rec.get('nameUser') != '') {
this.items[0].tooltip = 'del';
return 'icon-del';
} else {
this.items[0].tooltip = 'edit';
return 'icon-edit';
}
}
}]
}
And the css code: 和css代码:
.x-action-col-cell img.icon-del {
background-image: url("../images/delete.png");
}
.x-action-col-cell img.icon-edit {
background-image: url("../images/add.png");
}
or you can try this : 或者你可以尝试这个:
iconCls: me.readOnly==true ? iconCls:me.readOnly == true? 'icon-view' : 'icon-edit',
'icon-view':'icon-edit',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.