PDA

View Full Version : Add some Parameters to Form on Postback



shaoen01
25 Oct 2011, 6:13 PM
Hi,

I am currently using Form Fileupload example to upload a file and my server side will handle the backend processing. I would like to add a few parameters on to postback like how i do in the store code below. I added two extra parameters: request and task. I would like to do the same for the file upload example, but i'm having no luck.

Am i even able to do it this way similar to the store?

Store Code:


statustypestore = Ext.create('Ext.data.Store', {
model: 'StatusTypeModel',
proxy: new Ext.data.HttpProxy({
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
//type: 'jsonp',
type: 'ajax',
url: 'database.php',
extraParams: {
task: 'ListStatusType',
request: 'StatusType'
},
reader: {
root: 'results',
totalProperty: 'total'
},
// sends single sort as multi parameter
simpleSortMode: true
})
});


Fileupload inside the buttons:


buttons: [{
text: 'Save',
handler: function(){
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'add_file.php',
extraParams: {
task: 'ListStatusType',
request: 'StatusType'
},
waitMsg: 'Uploading your file...',
success: function(fp, o) {
msg('Success', 'Processed file "' + o.result.file + '" on the server');
}
});
}
}
}]

shaoen01
25 Oct 2011, 6:27 PM
It seems that form is using "params" instead of "extraParams". I am sharing my code below for those who might be facing same issue as myself:<br>
<br><pre class="bbcode_code" style="height:252px;">buttons: [{
text: 'Save',
handler: function(){
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'add_file.php',
<strong>params: {
task: 'ListStatusType',
request: 'StatusType'
},</strong>
waitMsg: 'Uploading your file...',
success: function(fp, o) {
msg('Success', 'Processed file "' + o.result.file + '" on the server');
}
});
}
}
}]