Results 1 to 4 of 4

Thread: Clicking browse after disabling file field opens the explorer

  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    12
    Answers
    1

    Default Answered: Clicking browse after disabling file field opens the explorer

    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.

  2. Fixed...tried disabling the field after show, it worked

  3. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    12
    Answers
    1

    Default

    Really stuck, with this...somebody please help!!

  4. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    12
    Answers
    1

    Default

    Fixed...tried disabling the field after show, it worked

  5. #4
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Glad to hear you found your solution, and thanks for taking the time to post it for others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •