1
我在网格布局中有一个动作列图标,点击图标我打开了一个窗口窗体面板。 然后点击图标我建立一个fieldset dynamicllay。 Fieldset包含按钮和图像。添加按钮在EXTjs中动态点击事件4
//Below is the code
for (var j = 0; j < productPictures.length; j++) {
var values = productPictures[j].value;
var idPic = productPictures[j].idProductPicture;
alert(idPic);
fieldset.add({
xtype: 'container',
layout: 'hbox',
items: [{
xtype: 'box',
autoEl: {
tag: 'img',
src: '/files/product/' + idProduct + '/picture/100x75/' + values,
height: '50px',
width: '50px'
}
}, {
xtype: 'button',
name: 'remove' + idPic,
width: 200,
text: 'Remove',
handler: function() {
alert(idPic);
Ext.Ajax.request({
url: '/admin/productpicture?id=' + idPic + '&memberId=' + idMember + '&idProduct=' + idProduct,
method: 'DELETE',
success: function (response) {
Ext.Msg.alert('Status', 'Image Deleted succesfullly.');
},
failure: function() {
Ext.Msg.alert('Status', 'There is an error.');
}
})
}
}]
})
}
是我收到的问题是我想要的按钮的处理程序,以接受与每个按钮其给出相同的值(循环的第一个值)。所以,如何的每looping.But的onclick来动态值使其具有动态性,以便我可以动态地为每个图像传递参数。
这可能有助于http://stackoverflow.com/questions/11204680/ext-js-pass-extra-param-to-handler – Ben 2013-02-26 12:21:49