Code:
this.formPanelAdd = new Ext.FormPanel({
border:true
,frame:true
,autoHeight:true
,fileUpload:true
,id:'formAddParse'
,labelWidth:100
,margins :'10 10 10 10'
,buttonAlign :'right'
,bodyStyle :'padding-top:10px'
,items:[{
border:false
,layout:'column'
,anchor:'100%'
,monitorValid:true
,autoHeight:true
,defaults:{
columnWidth:1
,autoHeight:true
,border:false
,layout:'form'
,hideLabel:true
},
items: [{
anchor:'-25',
items:[{
xtype:'fileuploadfield',
fieldLabel: 'File',
name:'filepath',
allowBlank:false,
tabIndex:1,
autoWidth:true,
id:'formAddParseFilePath'
},{
xtype:'textarea',
fieldLabel:'Comment',
name:'filecomment',
tabIndex:2,
width:370,
id:'formAddParseFileComment'
},{
xtype:'combo',
name:'filetype',
fieldLabel:'Type',
mode:'local',
store:this.storeTypeFile,
valueField:'typeName',
displayField:'typeName',
forceSelection :true,
allowBlank :false,
lazyRender :true,
editable :false,
triggerAction :'all',
hiddenId:'idType',
tabIndex:3,
width:370,
id:'formAddParseFileType'
},{
xtype:'textfield',
fieldLabel:'Template',
name:'filetemplate',
allowBlank:false,
tabIndex:4,
width:370,
id:'formAddParseFileTemplate'
}]
}]}],
buttons:[{
text:'Upload and save',
iconCls:'icon-ok',
scope:this,
handler:this.onUploadAndSave,
tabIndex:5
},{
text:'Cancel',
iconCls:'icon-cancel'
,tabIndex:6
,scope:this
,handler:function(el, ev){
Ext.getCmp('uploadParsefileWindow').close();
}
}]
,keys:[{
key:[10,13] // enter
,scope:this
,stopEvent:true
,fn:this.onUploadAndSave
}]
});
Here the handler for the upload button :
Code:
onUploadAndSave:function(){
cc("upload and save clicked");
var form = Ext.getCmp('formAddParse').getForm();
if(form.isValid()){
var parseFile= {
name:Ext.getCmp("formAddParseFilePath").getValue(),
template:Ext.getCmp("formAddParseFileTemplate").getValue(),
comment:Ext.getCmp("formAddParseFileComment").getValue(),
type:Ext.getCmp("formAddParseFileType").getValue(),
affiliate : {id:this.idAffiliate}
}
DwrParseFile.add(parseFile, {
callback:this.uploadFile,
scope:this
});
}
},
Here the callback for my dwr function, where the submit is done :