Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Toolbar separator

  1. #1
    Sencha User
    Join Date
    Mar 2007
    Posts
    49
    Vote Rating
    0
      0  

    Default Toolbar separator

    Hi all,
    it is possible to add separator to toolbar in specific index? like insertButton(idx,btn)

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,392
    Vote Rating
    858
      0  

    Default

    Yes, insertButton takes an Ext.Toolbar.Item
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    49
    Vote Rating
    0
      0  

    Default

    When i use tbar.insertButton(3, {xtype: 'tbseparator'});
    i get this (see attach) - on the left - separator in config, right - dynamic separator. it is like button
    Attached Images Attached Images

  4. #4
    Sencha User willgillen's Avatar
    Join Date
    Mar 2007
    Posts
    110
    Vote Rating
    0
      0  

    Default

    Try this instead:
    tbar.insertButton(3, "-");

    "-" is a shortcut for a tbseparator.

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    49
    Vote Rating
    0
      0  

    Default

    now i get this error "TypeError: Can't get property dom from null value"

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Posts
    49
    Vote Rating
    0
      0  

    Default

    any ideas?

  7. #7
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,113
    Vote Rating
    5
      0  

    Default

    Did anyone resolve this? I'm getting the same thing with Ext 2.2. Adding a separator dynamically using xtype: 'tbseparator' adds a blank button and addig a separator using '-' throws an error.

  8. #8
    Sencha User makana's Avatar
    Join Date
    Apr 2008
    Location
    Dresden, Germany
    Posts
    527
    Vote Rating
    21
      0  

    Default

    I think the docs is wrong, because insertButton only makes buttons out of configs...
    original code:
    Code:
    if (!(item instanceof T.Button)){
        item = new T.Button(item);
    }
    i use this one:
    Code:
    Ext.override(Ext.Toolbar, {
    	insertButton: function(index, item) {
    		var isField = false;
            if(Ext.isArray(item)){
                var buttons = [];
                for(var i = 0, len = item.length; i < len; i++) {
                   buttons.push(this.insertButton(index + i, item[i]));
                }
                return buttons;
            }
            if (item.isFormField) {
    			isField = true;
    		} else if(item.render) {
            	// do nothing
    		} else if(typeof item == "string"){ // string
    			if(item == "separator" || item == "-"){
    				item = new Ext.Toolbar.Separator();
    			}else if(item == " "){
    				item = new Ext.Toolbar.Spacer();
    			}else if(item == "->"){
    				item = new Ext.Toolbar.Fill();
    			}else{
    				item = new Ext.Toolbar.TextItem(item);
    			}
    		} else if (item.tagName) {
    			item = new Ext.Toolbar.Item(item);
    		} else if (typeof item == "object") {
    			if (item.xtype) {
    				item = Ext.ComponentMgr.create(item, 'button');
    				isField = true;
    			} else item = new Ext.Toolbar.Button();
    		} else return false;
            var td = document.createElement("td");
            
            if (isField) {
            	item.render(td);
            	item = new Ext.Toolbar.Item(td.firstChild);
            }
            
            this.tr.insertBefore(td, this.tr.childNodes[index]);
            this.initMenuTracking(item);
            item.render(td);
            this.items.insert(index, item);
            return item;
    	}
    });
    this is not very nice but should work. if not, i appreciate your suggestions!

  9. #9
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,113
    Vote Rating
    5
      0  

    Default

    @makana - Thanks! I'll try it out.

  10. #10
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    8
      0  

    Default

    Check:
    http://extjs.com/deploy/dev/docs/?cl...bar&member=add

    If you think there's a bug in the docs there's a thread dedicated to doc bugs...just post it and they'll clean it up eventually.

Page 1 of 2 12 LastLast

Posting Permissions

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