I'm trying to create a grouptabpanel dynamically so I'm calling a function to create all the elements.

What I have is:

Code:
    var vwport = new Ext.Viewport({
        layout: "fit",
        id: "vwpt",
        items:[{
            xtype: 'grouptabpanel',
            tabWidth: 210,
            activeGroup: 0,
            items:[
                createGroup("Test",1),
            {
                title: "Other options/products",
                mainItem: 0,
                items:[{
                    title: "Other options/products"
                },{
                    title: "Other 1"
                },{
                    title: "Other 2"
                }]
            }]
        }]
    });
where createGroup is the function that creates a Component and returns it. Obviously the first error is that the function getMainItem doesn't exist, as many others.

My question at this point is what kind of object should I create to contain all the functions, or how can I apply a good configuration, and in a future create it empty and use add to create groups and items dynamically.

Thanks,
Pau