ale*_*311 2 javascript grid extjs4
我有一个商店,里面有一个"Y"或"N"的字段.我想取Y或N值并在网格中放置一个绿色或红色的小图标而不是文本.我一直在搞乱条件渲染功能,但我无法弄清楚如何根据值显示图标.到目前为止我有
initComponent: function() {
this.columns=[
{header: 'PreReq', dataIndex: 'PreReq', width: 50,
renderer: function(value){
if(value == 'Y'){
//some code to put green icon in this cell
}
else if(value =='N'){
//come code to put red icon in this cell
}
else{
//some code to put error icon in this cell
}
}
}
];
this.callParent(arguments);
}
Run Code Online (Sandbox Code Playgroud)
它很简单:
return '<img src="..." />';
Run Code Online (Sandbox Code Playgroud)
或者如果你更喜欢css方式,你可以这样做:
renderer: function( value, metadata, record )
{
metadata.tdCls = 'yes-icon'
}
Run Code Online (Sandbox Code Playgroud)