trebor63
29 Oct 2009, 4:48 PM
Hello, I'm trying to implement a file import button for an editor grid in a Tab, to import an excel spreadsheet for example. But I seem to be running into a few difficulties.
The main problem is that the POST data is empty according both to firebug and the import function that is associated with the url statement in the code below.
The current button setup is below, which is just one of a few toolbar buttons already in place on the grid, but the only form in the toolbar, the id used does not conflict with the editorgrid id.
I am running on version 3.0.0
fbutton = {
xtype : 'form',
id : 'spreadForm',
fileupload : true,
hideLabels : true,
baseCls : 'x-toolbar-cell',
items : [{
xtype : 'fileuploadfield',
fileupload : true,
buttonOnly: true,
buttonText : 'Import..',
buttonCfg : {
iconCls : 'import'
},
name : 'importfile',
id : 'importfile',
listeners: {
'fileselected': function(fb, v) {
if (Ext.getCmp('spreadForm').getForm().isValid()) {
Ext.getCmp('spreadForm').getForm().submit({
fileupload : true,
url : '/process/spread/import/',
method : 'POST',
waitMsg : 'Validating Import...',
success : onSuccess,
failure : onFailure
});
} else {
alert("File upload form invalid");
}
}
}
}]
};
Alerting on the "v" variable passed to the fileselected event does supply the correct filename selected by the Import (browse) button.
I have tried the following with varying results
1) Setting standardSubmit to true -> the post functions here but it posts to the wrong url (the main page url) as opposed to the required url.
2) Not encapsulating the fileuploadfield in a form. I could not work out how to submit this.
3) Putting the url,method,waitMsg etc in the main form definitions, and not in the submit handler, putting them in both, with no apparent change in operation.
If I could get some pointers here as to where I can look, or what I can do, it would be greatly appreciated.
The main problem is that the POST data is empty according both to firebug and the import function that is associated with the url statement in the code below.
The current button setup is below, which is just one of a few toolbar buttons already in place on the grid, but the only form in the toolbar, the id used does not conflict with the editorgrid id.
I am running on version 3.0.0
fbutton = {
xtype : 'form',
id : 'spreadForm',
fileupload : true,
hideLabels : true,
baseCls : 'x-toolbar-cell',
items : [{
xtype : 'fileuploadfield',
fileupload : true,
buttonOnly: true,
buttonText : 'Import..',
buttonCfg : {
iconCls : 'import'
},
name : 'importfile',
id : 'importfile',
listeners: {
'fileselected': function(fb, v) {
if (Ext.getCmp('spreadForm').getForm().isValid()) {
Ext.getCmp('spreadForm').getForm().submit({
fileupload : true,
url : '/process/spread/import/',
method : 'POST',
waitMsg : 'Validating Import...',
success : onSuccess,
failure : onFailure
});
} else {
alert("File upload form invalid");
}
}
}
}]
};
Alerting on the "v" variable passed to the fileselected event does supply the correct filename selected by the Import (browse) button.
I have tried the following with varying results
1) Setting standardSubmit to true -> the post functions here but it posts to the wrong url (the main page url) as opposed to the required url.
2) Not encapsulating the fileuploadfield in a form. I could not work out how to submit this.
3) Putting the url,method,waitMsg etc in the main form definitions, and not in the submit handler, putting them in both, with no apparent change in operation.
If I could get some pointers here as to where I can look, or what I can do, it would be greatly appreciated.