Jump to content

Create dropdown menu for UniPageControl


artem_niko

Recommended Posts

28 minutes ago, artem_niko said:

I'm will be waiting answer from you.

Made the following:

1. UniMenuButton1
2. UniPageControl1.ClientEvents.ExtEvents -> function tabPanel.afterrender(sender, eOpts)

function tabPanel.afterrender(sender, eOpts)
{
    var tabItems=[];
    this.tabBar.getRefItems().forEach(function(item,i){
        tabItems.push({
            index: i, 
            text: 
            item.title, 
            handler: function(item){
                sender.setActiveItem(item.index)
            }
        })
    });
    this.addTool({
        text: 'Sheets', 
        xtype: 'splitbutton',  
        menu: new Ext.menu.Menu({items: tabItems})
    });
}

image.png.2d9fa4b443b4c762ea38f1266010591e.png

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

44 minutes ago, Sherzod said:

Made the following:

1. UniMenuButton1
2. UniPageControl1.ClientEvents.ExtEvents -> function tabPanel.afterrender(sender, eOpts)

function tabPanel.afterrender(sender, eOpts)
{
    var tabItems=[];
    this.tabBar.getRefItems().forEach(function(item,i){
        tabItems.push({
            index: i, 
            text: 
            item.title, 
            handler: function(item){
                sender.setActiveItem(item.index)
            }
        })
    });
    this.addTool({
        text: 'Sheets', 
        xtype: 'splitbutton',  
        menu: new Ext.menu.Menu({items: tabItems})
    });
}

image.png.2d9fa4b443b4c762ea38f1266010591e.png

Incredible! Excellent! Thank's, @Sherzod! :)

One small question: how add icon (icon as in all tab sheets in ImageIndex)?

  • Thanks 1
Link to comment
Share on other sites

Thanks.

12 minutes ago, artem_niko said:

One small question: how add icon (icon as in all tab sheets in ImageIndex)?

I think you can simply use fontawesome icon:

function tabPanel.afterrender(sender, eOpts)
{
    var tabItems=[];
    this.tabBar.getRefItems().forEach(function(item,i){
        tabItems.push({
            iconCls: 'x-fa fa-columns',
            index: i, 
            text: 
            item.title, 
            handler: function(item){
                sender.setActiveItem(item.index)
            }
        })
    });
    this.addTool({
        text: 'Sheets', 
        xtype: 'splitbutton',  
        menu: new Ext.menu.Menu({items: tabItems})
    });
}

 

Link to comment
Share on other sites

7 hours ago, Sherzod said:

Thanks.

I think you can simply use fontawesome icon:

function tabPanel.afterrender(sender, eOpts)
{
    var tabItems=[];
    this.tabBar.getRefItems().forEach(function(item,i){
        tabItems.push({
            iconCls: 'x-fa fa-columns',
            index: i, 
            text: 
            item.title, 
            handler: function(item){
                sender.setActiveItem(item.index)
            }
        })
    });
    this.addTool({
        text: 'Sheets', 
        xtype: 'splitbutton',  
        menu: new Ext.menu.Menu({items: tabItems})
    });
}

 

How use this?

image.thumb.png.26d7787363dda255c4e3154b3dfc1c39.png

 

So, I can't use UniNativeImageIndex? Why? May be this JS code possible write in OnCreate and set imageindex from UniNativeImageIndex?

Link to comment
Share on other sites

1 hour ago, artem_niko said:

I'm using different icons for tab sheet's...

Okay, then just use this modified code:

function tabPanel.afterrender(sender, eOpts)
{
    var tabItems=[];
    this.tabBar.getRefItems().forEach(function(item,i){
        tabItems.push({
            //iconCls: 'x-fad fa-diagram-project',
            icon: item.icon,
            index: i, 
            text: item.title, 
            handler: function(item){
                sender.setActiveItem(item.index)
            }
        })
    });
    this.addTool({
        text: 'Sheets', 
        xtype: 'splitbutton',  
        menu: new Ext.menu.Menu({items: tabItems})
    });
}

image.png.535a3e0486addeb2614d19903d8e0994.png

  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Sherzod said:

Okay, then just use this modified code:

function tabPanel.afterrender(sender, eOpts)
{
    var tabItems=[];
    this.tabBar.getRefItems().forEach(function(item,i){
        tabItems.push({
            //iconCls: 'x-fad fa-diagram-project',
            icon: item.icon,
            index: i, 
            text: item.title, 
            handler: function(item){
                sender.setActiveItem(item.index)
            }
        })
    });
    this.addTool({
        text: 'Sheets', 
        xtype: 'splitbutton',  
        menu: new Ext.menu.Menu({items: tabItems})
    });
}

image.png.535a3e0486addeb2614d19903d8e0994.png

Excellent!
Everything I need.
One last question: can this UniMenuButton only be embedded in a UniPageControl, or can it be embedded in the header of a UniPanel, for example? Simply, in the case of the UniPageControl, a white bar appears that takes up space. If you embed a UniMenuButton in the header of a UniPanel, then you can additionally place buttons there, for example, later.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...