View Full Version : Issues displaying a grid in a window when the grid has an ID

27 Jul 2012, 5:03 AM
I've been working in Architect 2 to experiment with Ext 4.0.7 and am seeing what I think is odd behavior with a grid in a window. I believe this is more of an Ext issue than Architect, so I'm posting here.

The actual window I've tried to build is more complex than this example, but I've produced a relatively simple example that illustrates the issues.

I've seeing 2 odd behaviors, both of which only happen when I assign a value for the id property on the Ext.grid.gridpanel:
1 - If a grid with an id is directly in a window, it does not display. Actually close examination of the HTML shows that the grid is there, but is not expanded properly in the layout.
2 - If the window has a fit layout, and I add a panel (Ext.panel.Panel) to the window, then put the grid (with an id value) in the panel, then the grid displays, but if the layout on the panel is 'vbox' or 'auto' the initial data in the grid is duplicated (there's 2 sets of the same rows). The grid seems fine if the panel uses a fit layout.
Now in this very simple example I think I'd want the intermediate panel to use a fit layout anyway, but in my more complex example that isn't necessarily the case.

I've attached 2 copies of the whole 'project'.
One version is without the intermediate panel, demonstrating how the grid does not show. If you remove the id property from the grid in that sample, then it works.
The other version has the intermediate panel and demonstrates the duplicated data. That version can be fixed by either removing the id on the grid or changing the panel layout to fit.
Note that either can be corrected by not assigning an id to the grid, but it seems like you might want an id on the grid for some code to work the way you want it to.
I'll also note that I don't think any of this happens when the grid is not in a window, so it may be that the window parent plays a role.

Does anyone have any expalanations for the odd behavior when the grid has an id value? Is there something I'm not doing correctly in the examples?

Kent Piland

27 Jul 2012, 10:53 AM
I think I've figured out my own problem.
In my application launch event, I had this:

var win = Ext.create('MyApp.view.MyWindow').show();
Aside from the fact I shouldn't have been assigning the show result to a 'win' variable (duh), the creation is the problem. I'm pretty sure that the create was causing me to really have 2 instances of the window, and that just wasn't working right. I'd guess that the ID itself was causing this to misbehave. The window is the main view in the application, so I'm assuming the application automatically creates the window. By setting autoShow=true on the window and removing the create from the application launch, then everything seems to behave as I'd expect.