EXTJS:TreePanel单击以更改设置的项目

| 大家好 我是extjs的初学者,当我单击一个节点时,我对更改/将项目设置为布局存在疑问。 这是我的contentPanel:
var contentPanel = {
    id: \'content-panel\',
    region: \'center\', // this is what makes this panel into a region within the containing layout
    layout: \'card\',
    margins: \'2 5 5 0\',
    activeItem: 0,
    border: false,
    items: layoutExamples // HERE I WANT TO CHANGE DYNAMIC
};
我在treenode上的“监听器”:
treePanel.getSelectionModel().on(\'select\', function(selModel, record) {
    if (record.get(\'leaf\')) {
        //Ext.getCmp(\'content-panel\').layout.setActiveItem(record.getId() + \'-panel\'); <== It\'s work.
        Ext.getCmp(\'content-panel\').setActive(formPanel); // HERE I TRY TO CHANGE ITEM ON CLICK AND SET FORMPANEL 

});
我的测试项目:
var formPanel = Ext.create(\'Ext.form.Panel\', {
    frame: true,
    title: \'Form Fields\',
    width: 340,
    bodyPadding: 5,

    fieldDefaults: {
        labelAlign: \'left\',
        labelWidth: 90,
        anchor: \'100%\'
    },

    items: [{
        xtype: \'textfield\',
        name: \'textfield1\',
        fieldLabel: \'Text field\',
        value: \'Text field value\'
    }, {
        xtype: \'textfield\',
        name: \'password1\',
        inputType: \'password\',
        fieldLabel: \'Password field\'
    }, {
        xtype: \'filefield\',
        name: \'file1\',
        fieldLabel: \'File upload\'
    }, {
        xtype: \'textareafield\',
        name: \'textarea1\',
        fieldLabel: \'TextArea\',
        value: \'Textarea value\'
    }   }]
});
因此,我的目标是在单击节点时更改内容面板的项目。 非常感谢您的帮助!     
已邀请:
        试试看,并在评论中告诉我:
var formPanel = Ext.create(\'Ext.form.Panel\',
    {
        \'id\': \'form-panel-1\', // or what you want to give
        // and all the properties you already defined
    }
);
并且在您的情况下,基于http://docs.sencha.com/ext-js/4-0/#/api/Ext.layout.container.Card-method-setActiveItem:
treePanel.getSelectionModel().on(\'select\', function(selModel, record) {
    if (record.get(\'leaf\')) {
        Ext.getCmp(\'content-panel\').getLayout().setActiveItem(Ext.getCmp(\'form-panel-1\'));
    }
});
顺便说一句,在您提供的代码中,侦听器中有一个错误,它缺少用于结束if的}。     

要回复问题请先登录注册