PDA

View Full Version : how to refresh the grid, not render it again.



mysticav
30 Mar 2007, 10:26 PM
Hi,

I'm creating a grid which is stored in a global object.

The grid is rendered in a div inside a tab panel.

after changing from tab to tab, and coming back again to the grid, I need to mouseover it in order to turn it visible again.

I wonder if there's a way like
myGrid.refresh();

is useless to call myGrid.render();

Because everything is already in memory.

Any Idea ?

mysticav
31 Mar 2007, 3:03 PM
Data.Store.reload() ??

jeffiel
31 Mar 2007, 3:17 PM
use grid.getView().refresh()

does a redraw. I find that if I change the column model, i need to use getView().render

do not use grid.render() more than once, as it will install duplicate handlers.

mysticav
31 Mar 2007, 3:24 PM
getView().refresh() almost worked. The problem is that the header is not shown.

mfoley
3 Apr 2007, 12:55 PM
I had the same problem, and on top of that, everytime i clicked an editable cell in any of my grids, the focus wouldn't hold. The following fixed both.

(At the top your custom js file, before Ext.onReady or anything like that)

Ext.grid.RefreshingEditorGrid = function(container,config){
Ext.grid.RefreshingEditorGrid.superclass.constructor.call(this,container,config);
this.rendered = false;
}
Ext.extend(Ext.grid.RefreshingEditorGrid,Ext.grid.EditorGrid,{
refresh:function(){
/* grid.render is the first instance that grid.getView() is
called, and it sets grid.view to the returned variable.
Thus, call grid.render() if it hasn't been.
*/
if(!this.view) this.render();
else this.getView().refresh();
}
});
That way you can instantiate with something like:

grid = Ext.grid.RefreshingEditorGrid('grid-id',config);
And later call:

panel.on("activate",grid.refresh,grid);
Just make sure you explicitly call

layout.get(panelId).activate();
To clear the air, layout is the layout containing your ContentPanel, panel is the content panel containing your grid, panelId is the id of the div used to add to the layout, and grid is the EditorGrid in question.

And Jack, should you read this, I think it'd be an easy thing to bend a bit into being part of Ext.grid.Grid on the next rev :)