PDA

View Full Version : reposition the menu on a splitbutton



spiderweb
14 Aug 2009, 3:52 AM
How to reposition the menu on a splitbutton (to set it a few pixels to the left to be more precise), I don't want the horizontal scroll to appear when the menu is loaded like in the image...

Animal
14 Aug 2009, 4:46 AM
Add this override.



Ext.override(Ext.BoxComponent, {
doConstrain: function() {
if (this.rendered) {
this.container = this.el.dom.parentNode;
this.constrain = true;
Ext.Window.prototype.doConstrain.call(this);
}
},

showAt : function(xy, parentMenu, /* private: */_e){
this.parentMenu = parentMenu;
if(!this.el){
this.render();
}
if(_e !== false){
this.fireEvent("beforeshow", this);
xy = this.el.adjustForConstraints(xy);
}
this.el.setXY(xy);
this.el.show();
this.doConstrain();
this.hidden = false;
this.focus();
this.fireEvent("show", this);
},

});

spiderweb
14 Aug 2009, 4:50 AM
thanks :)

Animal
14 Aug 2009, 5:10 AM
Maybe this works better?



Ext.override(Ext.BoxComponent, {
showAt : function(xy, parentMenu, /* private: */_e){
this.parentMenu = parentMenu;
if(!this.el){
this.render();
}
if(_e !== false){
this.fireEvent("beforeshow", this);
}
xy = this.el.adjustForConstraints(xy);
this.el.setXY(xy);
this.el.show();
this.hidden = false;
this.focus();
this.fireEvent("show", this);
}
});