1. #1
    Ext User Joey Kwon's Avatar
    Join Date
    Jul 2009
    Location
    Seoul
    Posts
    2
    Vote Rating
    0
    Joey Kwon is on a distinguished road

      0  

    Default How to insert an item(button) between...

    How to insert an item(button) between...


    How to insert an item(button) between two items(buttons) at the panel.toolbar??

    I need to insert an item between items at toolbar after items made.
    I searched for a while...
    there was no solution...

    Code:
     items:[{
            text: 'Home',
            iconCls: 'silk-application-home',
            handler: function() {
              alert('clicked Home button');
            }
           // HERE
          },'-',{
            text: 'Logout',
            iconCls: 'silk-user-go',
            handler: function() {
              alert('Clicked Logout button');          
            }
          }]
    I know there is a way to solve this problem but like
    make that invisible first... pop that later by flag

    but I want to make that like... add() or extend()... after they made

    let me know the solution of this problem...
    Don't wait to door open...
    do something~!!

    Joey Kwon
    fangfifu@gmail.com

  2. #2
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    256
    Vote Rating
    1
    brookd is on a distinguished road

      0  

    Default


    toolbar.insertButton(index, item)

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    256
    Vote Rating
    1
    brookd is on a distinguished road

      0  

    Default


    Sorry, that code is for Ext3.0. For 2.2 you would have to do something like:

    Code:
    Ext.override(Ext.Toolbar, {
    	insertField : function(index,field){
             var td = document.createElement("td");
             this.tr.insertBefore(td, this.tr.childNodes[index]);
             this.initMenuTracking(field);
             field.render(td);
             this.items.insert(index, field);
             return field;
    	}
    })
    This should work for butttons aswell as fields...

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    You should just be able to use the normal container method insert() ... very similar to insertButton().

    Don't forget you may need to call doLayout() afterwards.

  5. #5
    Ext User Joey Kwon's Avatar
    Join Date
    Jul 2009
    Location
    Seoul
    Posts
    2
    Vote Rating
    0
    Joey Kwon is on a distinguished road

      0  

    Smile Thanks~!!!

    Thanks~!!!


    I'm using 3.0
    so I tried the first method..

    Code:
    insertButton(index, items);
    That works well enough...

    Let me see what I did before...
    very simple... but messy...

    Code:
    var logout = Ext.getCmp('logout'); // is this method to get the component is good?
    toolbar.remove(logout);
    toolbar.addItem([
        {
          text: 'Administrator',
          tooltip: 'Changing mode to admin',
          iconCls: 'silk-arrow-refresh',				
          handler: function(){
            alert('Clicked Administrator button');
          }
        },'-',{
          text: 'Logout',
          id:'logout',
          tooltip : 'Log out from this session.',
          iconCls: 'silk-user-go',
          handler: function() {
            alert('Clicked Logout button');          
          }
        }
    ]);
    Thanks again for your help guys...
    Don't wait to door open...
    do something~!!

    Joey Kwon
    fangfifu@gmail.com

Thread Participants: 2