1

I have created a toolbar with menu item in it:

Ext.create('Ext.toolbar.Toolbar', {
    renderTo: document.body,
    padding: '30 0 0 0',
    width   : '100%',
    items: [
        {
            xtype: 'splitbutton',
            text : 'File',
            menu: Ext.create('Ext.menu.Menu', {
                  width: 200,
                  margin: '0 0 10 0',
                  items: [
                      {
                          text: 'Import',
                          // code here
                      }
                  ]
            })
         }
    ]
});

So what I am trying to do is to be able to use Import button just like File->Open.
I know that I can add xtype: 'filebutton', but it shows the browse button with the text field.
Also I want to let the user to choose only certain file extensions. After file is selected (we click open), I want to add it to my file tree in my viewport.

Thanks for any help.

4

1 回答 1

0

我通过使用xtype: 'fileuploadfield'和隐藏文件名/​​文本字段来解决这个问题。

xtype: 'fileuploadfield',
buttonText : 'Open',
buttonOnly: true, 

它很简单。只需创建一个toolbar并将此代码放在其item字段中即可。

于 2013-05-27T21:10:25.560 回答