PDA

View Full Version : Cannot disable grid's handling of the scroll wheel


tsprague
04-23-2007, 12:10 PM
I have a grid with autoHeight set to true so that scroll bars never appear in the grid. Instead i want to scroll the document when the grid is too large to fit on one screen. The problem is that the grid captures scroll wheel events and prevents them from propagating so that you can't scroll the document when the mouse is over the grid. It would be nice if there was a grid option to disable handling of the mousewheel and scrolling in general.

Barring that i thought i could just remove the mousewheel event handlers from the grid view's body but removeListener doesn't appear to work on mousewheel events. Any suggestions, workarounds? Thanks

tbarstow
04-27-2007, 10:11 AM
Just figured out a way to fix this! Technically I am breaking encapsulation (big time) by doing this, but it's worth it to me; I keep all my adapters like this is a single file, so that on version change I only have one file to grok.


Ext.grid.GridView.prototype._handleWheel = Ext.grid.GridView.prototype.handleWheel;
Ext.grid.GridView.prototype.handleWheel = function(e) {
this.mainTable = this.mainTable || Ext.get(this.mainBody.dom.firstChild);
if (this.grid.wheelCapture == 'overflow') {
if (this.mainTable.getHeight() > this.mainBody.getHeight()) {
this._handleWheel(e);
}
} else if (this.grid.wheelCapture !== false && this.grid.wheelCapture != 'never') {
this._handleWheel(e);
}
};


This allows you to specify config option "wheelCapture" to your grid; wheelCapture can be one of:


"never" or false: never capture mouse wheel (this sounds like what you want)
"overflow": only capture mouse wheel when there is overflow within the grid to scroll (this is what I wanted in my app)


Jack et al, is there any way to get this (or something like it) into the next release?

tsprague
04-27-2007, 11:52 AM
Thanks tbarstow!