View Full Version : Basic Query For Ext.override

27 May 2011, 2:39 AM

I've been tearing my hair out on this, and it's probably really simple, but where do I put my override code?

I have this code which overrides a function in GridView to allow autoHeight and maxHeight to be used, which I got from this post (http://www.sencha.com/forum/showthread.php?31093-GridPanel-maxHeight):

layout : function(){
return; // not rendered
var g = this.grid;
var c = g.getGridEl();
var csize = c.getSize(true);
var vw = csize.width;

if(vw < 20 || csize.height < 20){ // display: none?

if (g.maxHeight) {
var hdHeight = this.mainHd.getHeight();
var vh = Math.min(csize.height, g.maxHeight);
this.el.setSize(csize.width, vh);
this.scroller.setSize(vw, vh - hdHeight);
} else {
this.scroller.dom.style.overflow = 'visible';
this.el.setSize(csize.width, csize.height);

var hdHeight = this.mainHd.getHeight();
var vh = csize.height - (hdHeight);

this.scroller.setSize(vw, vh);
this.innerHd.style.width = (vw)+'px';
if(this.lastViewWidth != vw){
this.fitColumns(false, false);
this.lastViewWidth = vw;
}else {
this.onLayout(vw, vh);

Reading through it, it looks fine. But where does it go?!

I'll explain my problem just in case it helps:

I have a grid, and the number of records in it varies.
I want the grid to use autoHeight until it reaches a certain height, after which I would want the maxHeight to kick in, which would enable the scroll bars as well.

Thanks in advance,


27 May 2011, 5:23 AM
But where does it go?!

Personally, I create an overrides.js file for all my overrides, and include that as the last JS file in my head section.

27 May 2011, 6:08 AM
thanks for the reply fay. I have done that but I guess the code I'm using to override is not right.

Like I mentioned before, I want to set a maxHeight when autoHeight = true.
So when there are a few records, autoHeight will take care of the height, but once the height reaches the maxHeight, auotHeight = false, and the scrollbars will appear.

I'm struggling to decipher the code I found from the other thread, do you think it works?

Thanks again.