PDA

View Full Version : How to insert an item(button) between...



Joey Kwon
10 Jul 2009, 1:26 AM
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...


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...

brookd
16 Jul 2009, 3:08 PM
toolbar.insertButton(index, item)

brookd
16 Jul 2009, 3:10 PM
Sorry, that code is for Ext3.0. For 2.2 you would have to do something like:



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...

mjlecomte
16 Jul 2009, 4:36 PM
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.

Joey Kwon
16 Jul 2009, 5:34 PM
I'm using 3.0
so I tried the first method..


insertButton(index, items);

That works well enough...

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



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...