I have a DataView which displays a list of images loaded from a JsonStore. However, the label required for each image is not an available attribute within the JsonStore - in other words, for each record in the store, I need to fetch (via an AJAX request) the label from another service.
Is is possible to call a custom function to grab the label before each image is displayed from the JsonStore?
Here's my current implementation:
var view = new Ext.DataView({
store: new Ext.data.JsonStore({
autoLoad:false,
root: 'root',
id:'ID',
fields:['ID']
}),
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div class="wrapper" id="{ID}">',
'<div class="thumb"><a href="'+ URL +'{ID}" title="{*label here*}">',
'&开发者_StackOverflow中文版lt;img src="'+ THUMB_URL +'{ID}"></a></div>',
'<span>{*label here*}</span></div>',
'</tpl>'
)
});
Thanks!
Apologies for answering my own question, but it looks as if prepareData does exactly what I want - allowing me to act on each individual record in the store before it's sent out for formatting.
精彩评论