1. #1
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    650
    Vote Rating
    52
    Answers
    30
    Zdeno is a jewel in the rough Zdeno is a jewel in the rough Zdeno is a jewel in the rough

      0  

    Default Unanswered: Ext.form.field.File + setVisible

    Does anybody know correct way how to hide/show form.field.File? When you call
    PHP Code:
    field.setVisible(false); 
    the button is totally broken (width is arround 5px and text is missing).
    The best solution i tested is:
    PHP Code:
    field.bodyEl.up('table').setDisplayed(false);
    field.hidden true

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,093
    Vote Rating
    228
    Answers
    488
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default

    In 4.1.1 setVisible(false) and hide() work for me, though I'm not seeing the field when doing a show() or setVisible(). But, the showing is not working for me when working with a file field or a textfield (within a form).

    Not any better for me in 4.2 beta.
    Thought formpanel.updateLayout() or suspend/resumeLayouts might help, but no dice.

    For what it's worth here's my test code.
    Code:
    Ext.create('Ext.form.Panel', {
        renderTo: Ext.getBody(),
        width: 500,
        frame: true,
        title: 'File Upload Form',
        bodyPadding: '10 10 0',
    
    
        defaults: {
            anchor: '100%',
            allowBlank: false,
            msgTarget: 'side',
            labelWidth: 50
        },
    
    
        items: [{
            xtype: 'textfield',
            fieldLabel: 'Name'
        },{
            xtype: 'filefield',
            id: 'form-file',
            emptyText: 'Select an image',
            fieldLabel: 'Photo',
            name: 'photo-path',
            buttonText: 'upload',
        }],
    
    
        buttons: [{
            text: 'Save',
            handler: function(){
                var form = this.up('form').getForm();
                if(form.isValid()){
                    form.submit({
                        url: 'file-upload.php',
                        waitMsg: 'Uploading your photo...',
                        success: function(fp, o) {
                            msg('Success', 'Processed file "' + o.result.file + '" on the server');
                        }
                    });
                }
            }
        },{
            text: 'Reset',
            handler: function() {
                this.up('form').getForm().reset();
            }
        }, {
            text: 'Hide',
            enableToggle: true,
            handler: function (btn, pressed) {
                var ff = btn.up('form').down('filefield');
                pressed ? ff.hide() : ff.show();
            }
        }]
    });

Thread Participants: 1