2

I have a button in dataview on click of which i have to open fileUpload browse. I have tried below code which seems to be working fine with Ext JS modern SDK but with classic el element is null.

Ext.application({
name: 'Fiddle',

launch: function () {
    var panel = Ext.Viewport.add({
        xtype: 'panel',
        title: 'FileInput Field Trigger',
        itemId: 'Mypanel',
        items: [{
            xtype: 'button',
            text: 'Upload file',
            listeners: {
                tap: function (button) {
                    // Find the fileinput field
                    var panel = button.up('#Mypanel');
                    var fileinput = panel.down('#myFileInputField');

                    // Programmatically click the file input field
                    fileinput.el.query('input[type=file]')[0].click();
                }
            }
        }, {
            xtype: 'formpanel',
            hidden: true,
            items: [{
                xtype: 'filefield',
                itemId: 'myFileInputField',
                listeners: {
                    change: function (field, newValue, oldValue, eOpts) {
                        Ext.Msg.alert('Results', newValue);
                    }
                }
            }]
        }]
    });
}
});

Is there any method to trigger this event or any other approach please.

2
  • The tap event is being fired on classic sdk? Commented Jun 12, 2019 at 11:40
  • no its click event in classic Commented Jun 12, 2019 at 11:59

1 Answer 1

3

If you are putting the exact above code in classic sdk, then, there are some things that are slightly different compared to modern sdk:

The form xtype in Classic is just 'form' and not 'formpanel'

In Classic there isn't a tap event for buttons, just a handler that is executed when the button is clicked:

items: [{
        xtype: 'button',
        text: 'My Button',
        handler: function(button) {
            console.log('you clicked the button ', button);
        }
}]

Checkout the working fiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.