PDA

View Full Version : [ACC] [3.0] buttons to support ' ', '-' and '->'


Condor
04-24-2009, 07:58 AM
Can the Ext.Panel buttons config option be made to support ' ', '-' and '->', just like tbar and bbar?

Suggested fix:
Ext.override(Ext.Panel, {
initComponent : function(){
Ext.Panel.superclass.initComponent.call(this);
this.addEvents(
'bodyresize',
'titlechange',
'iconchange',
'collapse',
'expand',
'beforecollapse',
'beforeexpand',
'beforeclose',
'close',
'activate',
'deactivate'
);
if(this.unstyled){
this.baseCls = 'x-plain';
}
if(this.tbar){
this.elements += ',tbar';
if(Ext.isObject(this.tbar)){
this.topToolbar = this.tbar;
}
delete this.tbar;
}
if(this.bbar){
this.elements += ',bbar';
if(Ext.isObject(this.bbar)){
this.bottomToolbar = this.bbar;
}
delete this.bbar;
}
if(this.header === true){
this.elements += ',header';
delete this.header;
}else if(this.title && this.header !== false){
this.elements += ',header';
}
if(this.footer === true){
this.elements += ',footer';
delete this.footer;
}
if(this.buttons){
this.elements += ',footer';
var btns = this.buttons;
this.buttons = [];
for(var i = 0, len = btns.length; i < len; i++) {
if(typeof btns[i] == 'string' || btns[i].render){
this.buttons.push(btns[i]);
}else if(btns[i].xtype){
this.buttons.push(Ext.create(btns[i], 'button'));
}else{
this.addButton(btns[i]);
}
}
}
if(this.fbar){
this.elements += ',footer';
}
if(this.autoLoad){
this.on('render', this.doAutoLoad, this, {delay:10});
}
}
});

jgarcia@tdg-i.com
04-24-2009, 09:24 AM
+1 !

mjlecomte
04-24-2009, 10:40 AM
FYI: http://extjs.com/forum/showthread.php?p=319238#post319238

Condor
04-27-2009, 12:53 AM
I know there are several workarounds (you can also specify {xtype: 'tbfill'} in the buttons array), but I would still like '-', ' ' and '->' to be supported directly.

Related request: Can Ext.menu.Menu also support ' ' and '->' so you can use the same config array to create both a toolbar and a context menu?

Ext.override(Ext.menu.Menu, {
lookupComponent: function(c){
var item;
if(c.render){
item = c;
}else if(typeof c == "string"){
if(c == "separator" || c == "-" || c == " " || c == "->"){
item = new Ext.menu.Separator();
}else{
item = new Ext.menu.TextItem(c);
}
}else if(c.tagName || c.el){
item = new Ext.BoxComponent({
el: c
})
}else if(typeof c == "object"){
Ext.applyIf(c, this.defaults);
item = this.getMenuItem(c);
}
return item;
}
});

mystix
04-27-2009, 02:15 AM
+1

i was doing this all along for the 2.x branch (which also required a related override in Panel.onRender()), but it'll definitely be good to see this in 3.x trunk