0
ExtJS 4.1。使用Ext.form.updateRecord()來上傳文件
讓我們想象一下,我們有一些形式:
Ext.define('App.view.editform', {
extend: 'Ext.form.Basic',
defaultType: 'textfield',
items: [
{
fieldLabel: 'Title',
name: 'title',
allowBlank: false,
}, {
xtype: 'textarea',
fieldLabel: 'Text',
name: 'text',
height: 160,
}, {
xtype: 'filefield',
fieldLabel: 'Image',
name: 'image',
}, {
xtype: 'hidden',
name: 'id',
},
],
});
和商店:
Ext.define('App.store.Store', {
extend: 'Ext.data.Store',
model: new Ext.data.Model({
fields: [
{name: 'id', type: 'int'},
{name: 'title', type: 'string'},
{name: 'text', type: 'string'},
],
proxy: {
type: 'ajax',
url: '/someurl',
reader: {
type: 'json',
root: 'results'
},
},
}),
autoLoad: true,
autoSync: true,
});
要修改Records
在Store
我們可以用我們的表格上loadRecord();
方法和updateRecord();
方法將變更提交Store
(然後到服務器)。但在服務器上,每個Record
都有與之相關的圖像。
updateRecord();
方法只提交文本字段到Store
。 Model
不能包含binary
類型字段。
那麼有沒有辦法使用表格updateRecord();
方法上傳圖片?