PDA

View Full Version : Template with some pictures only shows the first one again and again...



wurstkuchen
22 Sep 2009, 8:42 AM
Hey,

I use a datastore to get some imagenames out of my database.
These imagenames are feeding a template.
When the datastore is reloaded, the template will be overwritten.

When there are more then one pictures, the first one is shown again and again.
BUT: When you do a right-mouseclick on the image and inspect the properties, the image filename is correct! But the shown image is wrong! It is always the first one.

Do i have to call a renderer function or something?

Thank you!

The code:


DataStoreImage = new Ext.data.Store({
id: 'DataStoreImage',
proxy: new Ext.data.HttpProxy({
url: 'hlp.php',
method: 'POST'
}),
baseParams:{task: "getImages"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'image', type: 'string'},
{name: 'image_two', type: 'string'},
{name: 'image_three', type: 'string'},
{name: 'image_four', type: 'string'},

]),
});

DataStoreImage.on({
'load':{
fn: function(){
record = DataStoreImage.getAt(0);

ImageTemplate.overwrite('ImageDiv', {image: record.get('image'), image_two: record.get('image_two'), image_three: record.get('image_three'), image_four: record.get('image_four')});

},
scope:this
}
});

ImageTemplate = new Ext.Template(
'<img height="104" src="../images/216X104/{image}"',
'<img height="104" src="../images/216X104/{image_two}">',
'<img height="104" src="../images/216X104/{image_three}">',
'<img height="104" src="../images/216X104/{image_four}">',
);

hendricd
22 Sep 2009, 8:48 AM
Try:


ImageTemplate.overwrite('ImageDiv', record.data);

wurstkuchen
22 Sep 2009, 8:53 AM
Thx!

Works very well!

But why? :-)

Animal
22 Sep 2009, 10:27 AM
Don't you want to use a DataView?