Lazy Loading an unusually complex grid (pivot table)
Lazy Loading an unusually complex grid (pivot table)
I have a grid which I don't want to fully render until the tab on which it resides is displayed. Ordinarily I would do this by not loading the grid's store until the tab is displayed. However the grid in question is a pivot table /crosstab affair which I've hacked together so that it uses two stores... long story and if others are interested I'll publish the code when I have time.
Anyway, how it works is:
- load data store 1 (which is large);
- iterate over its records to create a column model and a second store
- create a grid using those (pivoted cell renderers look into store 1 for values)
To add a GridPanel to my layout region, the grid needs to exist first... and that means I'd need to load my expensive first store. So as I see it I have three options:
1) Hack GridPanel to work ok without a grid at first (or allow it to be changed) , extending it with a 'setgrid' method or similar
2) Hack ContentPanel to allow it to mutate into a GridPanel after its created
3) Have a proxy contentpanel which when clicked upon destroys itself and loads a gridpanel in its place - probably with a visible flash in the ui which I'm not keen on.
Yes, I would be interested to know how you implemented the pivot table/crosstab structure. I have been in the process of contemplating a design of such a beast and would be interested in seeing your approach.
okay I'm going for option 1.5 - extend ContendPanel as 'LazyGridPanel', which initially behaves just like a contentpanel but after a call to setGrid adopts the behaviour of a GridPanel. Hopefully!
Yes, that works really well. I've got three of these nasty pivot grids to adapt to this new 'LazyGridPanel' structure but I'll post some more details when I can.
I am struggling with a similar issue. When issuing my server request, I don't know what columns will be returned. Essentially a crosstab type query. I need to dynamically build the column model after the data has been returned and populate my gird. I've considered making two server requests, one to get the columns and another to get the actual store but this seems very inefficient.
Anyways, I'm interested to see how you iterate over the records to create the column model. Any code you can post or send would be great!