View Full Version : How do you lazy load a grid in a gridpanel?

27 Mar 2007, 8:09 AM
I have 4 grids in my interface, 2 of which show by default and I'd like to have the other 2 "hidden" grids lazy load when their tabs/regions are activated. I can't see how I can do this though since inorder to set a region with a grid panel to support the grid you have to pass an already rendered grid to the grid panel and then add it region it is in.

I've tried several ways but can get it to work without passing the grid to the panel and the panel to the region so the tabs even show up upon page load. Only convaluted thing I found to somewhat work was to initial with just a regular content panel in the region that is hidden, then upon click remove the panel and replace it with a new grid panel and then initialize the grid. But this seems like a huge hack/work around. Is there an easier way?

With 4 grids and 2025 calls to GetStyle (I presume from the grids, since without them it drops to 200) my page is taking 7 seconds to render( And this is with autoSizeColumns: false and no AutoExpand calls either :( I have to find a way to get the intial page to render faster, but I can't drop the 4 grids. If I could atleast only render 2 to start it may load a bit faster. Anyone know how I might do this?

28 Mar 2007, 3:09 PM
Are you loading all their datastores at the start? That may explain a lot of the calls. Just do a load when the panel is activated.

29 Mar 2007, 5:20 AM
No, infact I don't load any datastores on page load, the slow rending times is just from doing grid.render().

I did find that I could forstal the rendering itself and send the grid variable back to the gridpanel, however, you must also leave off any grid header and footer panels as well since they require the grid to be rendered. This includes paging and toolbars. In the end I decided to just leave it since inorder to have all this stuff lazy load after the page load would have taken another 50-100 lines of code. /sigh