2

I'm new to ExtJS, and I'm trying create a viewport with a navigation tree in the west region. I can't figure out why the following code renders the viewport, but not the tree; could someone help?

Ext.onReady(function() {

    var navTree = Ext.create('Ext.data.TreeStore', {
        root: {
            text: 'Root Node',
            expanded: true,
            children: [
                {
                    text: 'Child 1',
                    leaf: true
                },
                {
                    text: 'Child 2',
                    leaf: true
                }
            ]
        }
    });

    var vp = Ext.create('Ext.Viewport', {
        layout: 'border',
        defaults: {
            frame: true,
            split: true
        },
        items: [
            {
                id: 'titlePanel',
                height: 40,
                region: 'north'
            },
            {
                id: 'navPanel',
                store: navTree,
                width: 250,
                region: 'west',
                title: 'West Region',
                collapsible: true
            },
            {
                id: 'bodyPanel',
                region: 'center',
                title: 'Center Region'
            }
        ]
    });
});
4

1 に答える 1

1

Because there's nothing to tell the west region what sort of component it is made of, thus you render the default Ext.panel.Panel, rather than Ext.tree.Panel.

Include xtype: 'treepanel' config for the west panel.

于 2013-02-11T17:34:17.167 に答える