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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      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
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    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
  •