私は次のコードを持っています:
new Ext.DataView({
store: new Ext.data.JsonStore({
url: 'request/getAssetsJSON',
baseParams: {
_id: this.request._id
},
root: 'results',
fields: [ 'attachment', 'id', 'name', 'property', 'type' ],
autoLoad: true
}),
emptyText: 'No images to display',
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{name}">',
'<div class="thumb"><p>Test</p><img height="45" src="request/getAsset?id={id}&attachment={attachment}" title="{name}"></div>',
'<span class="x-editable">{name}</span></div>',
'</tpl>',
'<div class="x-clear"></div>'
)
})
request/getAssetsJSONによって送信されるJSONは次のとおりです。
[{"attachment":"img1.png","id":"4dc90e2a6ba440e37601d5d074011e2e","name":"img1"},
{"attachment":"img2.png","id":"4dc90e2a6ba440e37601d5d074011e2e","name":"img2"},
{"attachment":"img3.png","id":"4dc90e2a6ba440e37601d5d074011e2e","name":"img3"}]
私の問題は、DataViewが最後の画像(img3.png)のみを表示し、request/getAssetへのGETリクエストが1つしかないことです。
ExtJSがテンプレートを反復処理する方法、またはデータをロードする方法に問題があると思いますが、ここでは途方に暮れています。
誰かアイデアはありますか?