3
我想创建具有3列的网格。一列是'textfield',另外两列是我将编辑器设置为'filefield'的图像。在图像列上,我可以使用渲染器显示图像,但是当编辑或添加新图像时,我无法按浏览按钮浏览图像。这是我的代码。ExtJS4 - 如何在Grid中添加文件上传编辑器?
var grid = Ext.create('Ext.grid.Panel', {
title: 'Author',
store: Ext.data.StoreManager.lookup('authorStore'),
renderTo: 'authorGrid',
columns: [{
header: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield',
}
}, {
header: 'Icon',
dataIndex: 'iconImage',
renderer: function(val) {
return '<img src="' + val + '">';
},
editor: {
xtype: 'filefield',
allowBlank: false,
}
}, {
header: 'Background',
dataIndex: 'background',
renderer: function(val) {
return '<img src="' + val + '">';
},
editor: {
xtype: 'filefield',
allowBlank: false,
}
}],
selModel: Ext.create('Ext.selection.CheckboxModel'),
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2
})
],
tbar: [{
iconCls: 'icon-add',
text: 'Add',
handler: function() {
// add record
}
}, {
iconCls: 'icon-delete',
text: 'Remove',
handler: function() {
// remove selected records...
}
}, {
iconCls: 'icon-save',
text: 'Save',
handler: function() {
store.save();
}
}]
});
这是什么错误?我可以把'filefield'编辑器这样吗?是否可以单击网格上的保存按钮以保存网格数据并上传图像?
谢谢innerJL!你的方法解决了我的要求。 – 2012-02-02 02:19:43