1. #1
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    389
    Answers
    7
    Vote Rating
    17
    Zdeno will become famous soon enough

      0  

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

    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
    5,010
    Answers
    382
    Vote Rating
    183
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      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