View Full Version : Cannot read property 'isComponentLayout' of undefined

7 Jun 2012, 10:30 AM
I'm getting the error message "Cannot read property 'isComponentLayout' of undefined" in Context.js line 994.
if (layout.isComponentLayout && (ownerCtContext = ownerContext.ownerCtContext)) {
// This layout's ownerCt is in this run... The component associated with
// this layout (the "target") could be owned by the ownerCt's container
// layout or component layout (e.g. docked items)! To manage this, we keep
// two counters for these and one for the combined total:
if (ownerContext.target.ownerLayout.isComponentLayout) {http://www.sencha.com/forum/chrome-devtools://devtools/Images/errorIcon.pngUncaught TypeError: Cannot read property 'isComponentLayout' of undefined

} else {

when one of my panels attempts to render. I've narrowed down the problem to a specific child that I'm adding to the panel. The parent panel is a class that extends off of Ext.panel.Panel and has a vbox layout. Inside the panel I've added a combobox and a grid that show up fine if I exclude my third item, a complex chart+slider component. This chart+slider piece works fine in other parts of the application, but I'm initializing it differently here... I've got a Ext.create that occurs in response to an event on a different part of the page rather than declaring it as part of a items property in the parent (the other elements in this page are added the same way). Once the object has been initialized I'm calling this.add(myobject) to add it to the page.

The whole piece I've described above occurs within a card layout, and the card involved is not the one on screen initially. There are no exceptions during the init process or the add call, but when I switch cards to the one that contains the above components I get the exception message above. Using the debugger I confirmed that there is indeed no "ownerLayout" property on the ownerContext.target of this object. Something I find odd is that sometimes the object where the exception is caught is not my third component, but one of the two that works fine if the third one is not added. I suspect there is a layout timing issue going on here, but am having trouble tracking it down. I'm hoping someone else has run into a similar problem and could point me in the right direction. The last time I hit this particular exception the issue was that the object I was adding to the panel hadn't finished being initialized, but looking at the debugger I don't think thats the case here.

My code is a bit of a spaghetti mess... so here's an abstract breakdown instead:
1. Grid on another part of the page fires row selection
2. In card hidden from view, combobox is created and added to mypanel with default selection
3. Based on combobox selection another grid is created and added to mypanel
4. After grid is done loading, graph component is created and added to mypanel
5. navigate using card view to make mypanel activeItem (and hence visible/rendered)
6. exception occurs

if I skip the "add to mypanel" on the graph component it all works fine except that the graph isn't visible (it still interacts fine with behind the scenes tasks that update/refresh it).

Thanks for any assistance, I'm going to keep picking away at it in the meantime.

8 Jun 2012, 12:28 PM
I suspect that as you mentioned, you have 'spaghetti' code that is interfering with the layout.
The best way to confirm this is to create a small isolated test case that tries to duplicate your problem. If the problem persists, then it is a potential bug or a config error. If it does not, then you know you have external influences.


8 Jun 2012, 12:41 PM
It seems to be specifically related to the type of object I'm adding... when I replaced it with a panel or some other simple object it works fine. The spot its exceptioning out at doesn't make much sense to me, I don't know what populates that "ownerLayout" property on an object. If I had to hazard a guess I would guess that it's trying to do a layout within a parent that is missing or has been altered in some way... but since it works fine with "standard" xtypes it must be something in my component and not systematic. Thanks for the suggestions.