There are a couple of forces at work in DataGrid and the underlying _Grid that can cause the grid to shrink to just the height of its header row between fetches, and then re-grow itself. If you're experiencing the behavior you've described specifically while scrolled to the bottom of your page, your browser is likely "scrolling up" (so that its viewport's bottom aligns with the new bottom of the page), but then when the table loads new data and resizes again, your browser is still "scrolled up".
I spent some time digging around DataGrid and _Grid. There are really two causes for this that I've found:
DataGrid's _clearData function, which calls updateRowCount(0) (i.e. reducing the grid to 0 rows until the new results come in)
_Grid's _resize function, which sets its viewsNode's height style to '' if _autoHeight is true (which seems to be the case if either autoHeight is true, or is a number >= rowCount)
If you're not averse to messing with the source, you could simply remove one line of code from DataGrid._clearData and another one from _Grid._resize and be done with it; assuming you'd like a cleaner approach, however, I've attempted to subclass DataGrid with a couple of workarounds instead. See how this fares for you.
dojo.provide('my.DataGrid');
dojo.declare('my.DataGrid', dojox.grid.DataGrid, {
updateRowCount: function(inRowCount) {
if (inRowCount > 0) { //ignore requests to set rowCount to 0
this.inherited(arguments);
}
},
_resize: function(changeSize, resultSize) {
if (this._autoHeight) {
//sizeblink workaround
var _viewsNode = this.viewsNode;
this.viewsNode = {style: {height: ''}}; //_Grid._resize crash dummy
this.inherited(arguments);
this.viewsNode = _viewsNode;
//call post-functions again with node properly hooked
this.adaptWidth();
this.adaptHeight();
this.postresize();
} else {
this.inherited(arguments);
}
}
});
//carry over DataGrid's custom markupFactory, otherwise declarative won't work
my.DataGrid.markupFactory = dojox.grid.DataGrid.markupFactory;
Hope it helps, or at least provides insight. I wonder if this issue ought to be entered as a bug in dojo's trac...