Results 1 to 10 of 10

Thread: How to add a button into the panel title header?

  1. #1
    Ext JS Premium Member
    Join Date
    Jun 2011
    Posts
    33
    Answers
    1

    Default Answered: How to add a button into the panel title header?

    How to add a button into the panel title header right after the title?

  2. Code:
    var panel = new Ext.panel.Panel({
        renderTo : document.body,
        width    : 400,
        height   : 400,
        title    : 'Test'
    });
    
    panel.header.add({
        xtype : 'button',
        text  : 'Test'
    });

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    The header is basically a container using hbox layout (vbox if header is on left or right). Therefore you can use add/insert/remove on that header component. There is no config to do this, you will have to do it manually after the header is created.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Ext JS Premium Member
    Join Date
    Jun 2011
    Posts
    33
    Answers
    1

    Default

    How to get the title header container?

  5. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Quote Originally Posted by psewt View Post
    How to get the title header container?
    Check out the properties on the panel instance
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  6. #5
    Ext JS Premium Member
    Join Date
    Jun 2011
    Posts
    33
    Answers
    1

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Check out the properties on the panel instance
    I've already checked it and I thought it's headerCt, but it's not. If you know the property name post it here.

  7. #6
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Code:
    var panel = new Ext.panel.Panel({
        renderTo : document.body,
        width    : 400,
        height   : 400,
        title    : 'Test'
    });
    
    panel.header.add({
        xtype : 'button',
        text  : 'Test'
    });
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  8. #7
    Ext JS Premium Member
    Join Date
    Jun 2011
    Posts
    33
    Answers
    1

    Default

    Quote Originally Posted by mitchellsimoens View Post
    Code:
    var panel = new Ext.panel.Panel({
        renderTo : document.body,
        width    : 400,
        height   : 400,
        title    : 'Test'
    });
    
    panel.header.add({
        xtype : 'button',
        text  : 'Test'
    });
    Is it possible to align the buttons to the left, right after the title?

  9. #8
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Use insert instead of add
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  10. #9
    Ext Premium Member
    Join Date
    May 2010
    Posts
    19

    Exclamation

    Note: this does not work, if the panel is to be a child item of a container (i.e. the renderTo property is empty), because then panel is not rendered upon creating it.

    In this case add the buttons in a render-event handler instead.

    If the panel is collapsible, you'll have to use insert, starting with index 1.

  11. #10
    Sencha User castitas's Avatar
    Join Date
    Sep 2011
    Location
    US
    Posts
    116
    Answers
    3

    Default

    Ditto above. Unfortunately, the alignment is still a problem. I did this:
    Code:
            obj.header.add([{
                xtype: 'button',
                text : 'HI'
            },{
                xtype: 'component',
                flex: 1
            }])
    flex: 1 will put it about halfway, 5 three-quarters. I had to go to about 18 to get it where I wanted it.

    Edit: Changing the alignment to left will probably fix the centering issue
    word

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •