PDA

View Full Version : [OPEN] [FIXED]Floating components have no ownerCt property/floatParent is not documented



m4dc4p
11 Mar 2011, 10:38 AM
I have created a component which extends Ext.Component and set the "floating" attribute to true.

I need to get a reference to the container of the component so I can call getEl() on the container. I am trying to do this in onRender, but when that override is called ownerCt has been deleted!

The framework saves a reference to ownerCt in "floatParent" but that property isn't documented and I'm not sure if I should be using it.

Is this a documentation bug, framework bug, or my bug? If there is a guide for creating floating components please let me know.

Thanks for your time!

Justin

evant
12 Mar 2011, 9:24 PM
Small test case:



Ext.onReady(function() {

var c = Ext.create('Ext.Component', {
floating: true,
html: 'Foo!',
width: 100,
height: 100
});

Ext.create('Ext.panel.Panel', {
width: 400,
height: 400,
renderTo: document.body,
items: c
});
c.show();

console.log(c.ownerCt);
});

Animal
13 Mar 2011, 12:54 AM
Yes, this does need documenting.

I'll add some documentation about what's going on.

A floating Component cannot really have an ownerCt because there are upward links from layout managers which use the ownerCt to rearrange the ownerCt when the child changes size.

So a different reference is kept for floating Components, and that's floatParent. Well done on digging it all up yourself in the absence of docs!

m4dc4p
14 Mar 2011, 7:54 AM
A floating Component cannot really have an ownerCt because there are upward links from layout managers which use the ownerCt to rearrange the ownerCt when the child changes size.

So a different reference is kept for floating Components, and that's floatParent.

Maybe a "container" property that figures out which reference to return is appropriate? Then application code doesn't have to check if a component is floating or not.

Thanks for the response!

Animal
14 Mar 2011, 8:22 AM
I've just spent a good while composing some hopefully coherent and meaningful prose to describe the ins and outs of floating Components. It should make the next release of the lib and docs.

m4dc4p
17 Mar 2011, 11:06 AM
Did your write up make it into PR4? I'd love to read it.

Animal
18 Mar 2011, 4:58 AM
Didn't make it into PR4. You should see it soon though.