PDA

View Full Version : How to dsiable Html Upload File control in extjs



RashmiWagh
29 May 2013, 6:06 AM
HI,

Please let me know how to disable the html upload file control in extjs.

For example, I need to disable the file control on check of radio group.

on check listener of radio group,

the below code is not working.

Ext.get('file-upload-1').dom.isDisabled = true;


I am getting error as Microsoft JScript runtime error: Object doesn't support this action

slemmon
31 May 2013, 11:41 AM
You should be able to just disable() or setDisabled() the filefield. Below is an example:



var form = Ext.create('Ext.form.Panel', {
title: 'Upload a Photo',
bodyPadding: 10,
frame: true,
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
}, {
xtype: 'checkboxfield',
boxLabel: 'Check to disable filefield',
listeners: {
change: function (field, checked) {
field.prev().setDisabled(checked);
}
}
}],


buttons: [{
text: 'Upload',
handler: function() {
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'photo-upload.php',
waitMsg: 'Uploading your photo...',
success: function(fp, o) {
Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
}
});
}
}
}]
});


Ext.widget('tabpanel', {
renderTo: Ext.getBody(),
width: 400,
items: [form]
});