Results 1 to 3 of 3

Thread: Dynamically adding component in toolbar

  1. #1
    Ext JS Premium Member
    Join Date
    Feb 2010
    Location
    Vancouver, BC
    Posts
    224
    Vote Rating
    1
      0  

    Default Dynamically adding component in toolbar

    I do add checkbox into toolbar dynamically (it was fine in 4.0)
    but with 4.1 upgrade, I can add as before as below with no problem

    Ext.getCmp("toolbarID").add(checkbox);

    but layout is bit messed up, displaying the items diagonally.

    If you add the same component statically, it renders fine.

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,029
    Vote Rating
    1368
      0  

    Default

    This code:

    Code:
    Ext.create('Ext.panel.Panel', {
        renderTo    : Ext.getBody(),
        width       : 400,
        height      : 400,
        title       : 'Test',
        html        : 'Hello',
        dockedItems : [
            {
                xtype : 'toolbar',
                dock  : 'top',
                items : [
                    {
                        text    : 'Add Comp',
                        handler : function(btn) {
                            var toolbar = btn.up('toolbar');
    
                            toolbar.add({
                                xtype    : 'checkboxfield',
                                boxLabel : 'Checkbox'
                            });
                        }
                    }
                ]
            }
        ]
    });
    Got me this result:

    Screen Shot 2012-01-13 at 3.58.26 PM.png
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

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

  3. #3
    Ext JS Premium Member
    Join Date
    Feb 2010
    Location
    Vancouver, BC
    Posts
    224
    Vote Rating
    1
      0  

    Default

    Thanks for your reply.
    Just noticed that the problem in our code is caused by
    layout:
    { overflowHandler: "Scroller"}

    and trying to figure out why it is causing our issue.
    It seems to fine with below code, only until the checkbox overflows.


    Quote Originally Posted by mitchellsimoens View Post
    This code:

    Code:
    Ext.create('Ext.panel.Panel', {
        renderTo    : Ext.getBody(),
        width       : 400,
        height      : 400,
        title       : 'Test',
        html        : 'Hello',
        dockedItems : [
            {
                xtype : 'toolbar',
               layout: {                    overflowHandler: "Scroller"
                },
                dock  : 'top',
                items : [
                    {
                        text    : 'Add Comp',
                        handler : function(btn) {
                            var toolbar = btn.up('toolbar');
    
                            toolbar.add({
                                xtype    : 'checkboxfield',
                                boxLabel : 'Checkbox'
                            });
                        }
                    }
                ]
            }
        ]
    });
    Got me this result:

    Screen Shot 2012-01-13 at 3.58.26 PM.png

Posting Permissions

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