PDA

View Full Version : Clicking browse after disabling file field opens the explorer



ImSatan
13 Dec 2013, 6:27 AM
I have filefield inside a fieldset. I want to disable the filefield when it renders first time. I tried using filefield.disable()/setDisabled() to disable the filefield. It gets disabled but when I click disabled browse button it opens the windows explorer window.

Ext.define ('client.DatasourcePanel', {
extend:'Ext.form.Panel',
alias: 'widget.datasourcepanel',
frame:true
,autoHeight:true
,defaults: {width: 400}
,bodyStyle:'padding:10px 10px 10px 10px'
,storeLoaded:false
,defaultDomain:''
,initComponent : function() {
var me = this ;
Ext.applyIf(me, {
items: [{
xtype: 'radio'
,itemId: 'adradio'
,checked: true
,boxLabel: 'AD'
,name: 'datasource'
,inputValue: 'adlogin'
,panel: this
,listeners: {
change: function(radio, newValue, oldValue, eOpts) {
if(newValue) {
this.panel.child('#adfieldset').enable();
}else {
this.panel.child('#adfieldset').disable();
}
}
}
},{
xtype: 'fieldset'
,itemId:'adfieldset'
,collapsible: false
,panel: this
,items: [
Ext.createWidget('acmstaticcombo',{
itemId:'datasource-userdomain'
,anchor: '100%'
,fieldLabel: 'Username'
,data:[]
,margin: '8px 0px 0px 0px'
,listeners: {
scope:me,
select: me.onUserDomainChange
}
}),{
fieldLabel: 'Username'
,xtype: 'textfield'
,name: 'username'
,anchor: '100%'
,itemId: 'datasource-username'
,margin: '5px 0px 0px 0px'

},{
fieldLabel: 'Password'
,xtype: 'textfield'
,name: 'password'
,itemId: 'datasource-password'
,inputType: 'password'
,anchor: '100%'
,enableKeyEvents: true
,margin: '5px 0px 0px 0px'
,listeners: {
keypress: function(field, key) {
if (key.getKey() == key.ENTER) {
me.parentComponent.onOk();
}
}
}
},Ext.createWidget('staticcombo',{
itemId:'datasource-addomain'
,anchor: '100%'
,fieldLabel: 'Domain'
,data:[]
,margin: '5px 0px 8px 0px'
})
]
}, {
xtype: 'radio'
,itemId: 'csvradio'
,boxLabel: 'csv'
,name: 'datasource'
,inputValue: 'csvfile'
,panel: this
,listeners: {
change: function(radio, newValue, oldValue, eOpts) {
if(newValue) {
//this.panel.child('#csvfieldset').enable();
this.panel.child('#csvfieldset').child('#uploadCsv').enable()
}else {
//this.panel.child('#csvfieldset').disable();
this.panel.child('#csvfieldset').child('#uploadCsv').disable()
}
}
}
}, {
xtype: 'fieldset'
,itemId:'csvfieldset'
,collapsible: false
,panel: this
,items: [{
xtype: 'filefield'
,disabled:true
,itemId: 'uploadCsv'
,inputId:'uploadCsv'
,emptyText: 'Please select a csv/xls file to upload'


,fieldLabel: 'File'
,margin: '8px 0px 8px 0px'
,width: 375
,startValue:''}
]
}]
});
me.callParent(arguments);
}
});

As you can see from the code upon CSV radio button selection I enable the filefield and when other radio is checked I disable the file field. Initially the file field has to be disabled. Also after changing the radio box selection ie AD to CSV and again to AD, the filefield gets disabled and upon clicking browse button windows explorer doesnot open.

ImSatan
15 Dec 2013, 10:01 PM
Really stuck, with this...somebody please help!!

ImSatan
15 Dec 2013, 10:10 PM
Fixed...tried disabling the field after show, it worked

Gary Schlosberg
16 Dec 2013, 9:19 AM
Glad to hear you found your solution, and thanks for taking the time to post it for others.