我必须在列表的一行中设置带有文本的图像。但是要在运行时选择图像。
这是我的商店:
Ext.define('MyApp.model.Sample', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'uName', mapping: '@name' },
{ name: 'uId', mapping: '@id' }
]
}
});
在我的列表 itemTpl 中,我能够显示uName,并且我创建了一个假设返回所需图像的函数(getImageURL),那么我应该如何使用或者使用 上述uId的方式/语法是什么(其中值为 0 或 1)
这是我的清单:
itemTpl : new Ext.XTemplate("<img src=\"{[this.getImageURL()]}\" width=\"20\" height=\"20\"></img><span> {uName}</span>",
{
getImageURL : function()
{
// I have to return either of two images
// if uId = 0, return 'resources/images/Image0.png'
// if uId = 1, return 'resources/images/Image1.png'
}
}
),