Results 1 to 3 of 3

Thread: Vertical toolbar not resizing when changing button text

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Vote Rating

    Exclamation Vertical toolbar not resizing when changing button text

    Using the code below, I can click on Button 1 and it shortens the text on each button on the vertical toolbar. This correctly makes the toolbar thinner the first time it is clicked. When clicked a second time it expands the text again. This also works. However after clicking again (and thereafter) to shorten the text, it doesn't make the buttons or toolbar thinner. I would be grateful for any assistance on how to get it to work. Thanks.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
    <html xmlns="">
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>My App</title>
            <link rel="stylesheet" type="text/css" href="/tools/extjs4/resources/css/ext-all-gray.css" />
            <script type="text/javascript" src="/tools/extjs4/bootstrap.js"></script>
            <script type="text/javascript" src="js/app.js"></script>
    Ext.onReady(function() {
            Ext.create('Ext.container.Viewport', {
                    layout: 'border',
                    items: [{
                            region: 'center',
                            xtype: 'panel',
                            dockedItems: [{
                                    xtype: 'toolbar',
                                    dock: 'left',
                                    defaults: {
                                            textAlign: 'left'
                                    items: [{
                                            text: 'Button 1',
                                            handler: function() {
                                                    if (this.getText() == 'B 1') {
                                                            this.setText('Button 1');
                                                            Ext.getCmp('b2').setText('Button 2');
                                                    } else {
                                                            this.setText('B 1');
                                                            Ext.getCmp('b2').setText('B 2');
                                            id: 'b2',
                                            text: 'Button 2'

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    I can reproduce this on 4.0.7 but 4.1.0 beta 1 is acting as expected with resizing the width after numerous clicks on the first button.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2

    Think my support is good? Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Vote Rating

    Smile yes fixed thanks, though some other issues

    Thanks Mitchell. I have now downloaded 4.1.0 beta 1 and it has fixed the issue.

    Some related issues to note though are:
    • separators in the toolbar prevent the toolbar from resizing. I have tried calling doComponentLayout and forceComponentLayout on the separator which didn't help. Currently I am calling setWidth to achieve the result which is not ideal, as I want the width to be automatic.
    • setting a toolbar button's text to empty string results in the button icon losing its vertical centering. I have overcome this with css.
    • bootstrap.js seems to be missing from 4.1.0 beta 1, so I copied over the 4.0.7 version and it worked.
    • button textAlign now seems to be ignored in 4.1.0 beta 1, but was working in 4.0.7. I have overcome this using css, but thought I would mention it.

    btw, what I am really using this code for is to allow labels to be placed to the right of icons on a vertical toolbar, which can then be hidden to create extra room. I preferred this to just tooltips for 2 reasons: 1) tooltips are not very practical for touch screens, 2) it is faster and easier to scan the eye over all toolbar items at once to read what the icons do (for new, infrequent or forgetful users).

Tags for this Thread

Posting Permissions

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