PDA

View Full Version : Several important questions



bereal
6 Dec 2007, 2:39 AM
Hello and thank you for the great job

I've got a couple of questions which seem very important for me:


1. is there the way to know what Class is the particular object is member of?
For example:


var viewport = new Ext.Viewport();
console.log(Ext.gimmeClass(viewport)) // i want "Ext.Viewport" here...
2. Most of examples show creating of Layout items during creation of Layout itself. We use different approach and are used to add them dynamically after creation of Layout.

I like the Viewport component, let it have default layout Ext.layout.ContainerLayout: (http://extjs.com/forum/../deploy/dev/docs/output/Ext.layout.ContainerLayout.html)

var viewport = new Ext.Viewport();
How its supposed to add, for example, EditorGridPanel, to the created Viewport?

Documentation of Viewport and or ContainerLayout tells me absolutely nothing about adding items. I tried viewport.add, viewport.getLayout().add, and etc - it doesnt work

santosh.rajan
6 Dec 2007, 3:06 AM
Every ext container (viewport included) have a getEl() method which returns the underlying ext element. See docs for Element.
When you add a component to a container you call its doLayout() method. In your case it is
viewport.doLayout() after you add.

SeaSharp2
6 Dec 2007, 3:58 AM
myViewPort.add( myGridPanel );
myViewPort.doLayout();
Re. the other question about dynamic querying for an object's class type... unlike some other JavaScript prototype extention libraries I have not noticed a classname attribute in Ext objects.

bereal
6 Dec 2007, 4:00 AM
Thanks guyz.

I read about Viewport that it automatically redraws everything by itself and had no idea that I need to do it myself :)))

its very pity abt first question

brian.moeskau
6 Dec 2007, 5:48 AM
You can use basic JavaScript functions like typeof for determining JS object type. You can also use several methods of Component like isXType, getXType and getXTypes to determine the Ext-specific class types.

SeaSharp2
6 Dec 2007, 7:06 AM
You can also use several methods of Component like isXType, getXType and getXTypes
Nice! Looks like a recent enhancement.

I went back and read up on the typeof JavaScript operator, it will only return 'object' according to the docs.