0

みなさん、こんにちは。私はextjsを始めていますが、ノードの1つをクリックすると、アイテムをレイアウトに変更/設定する際に問題が発生します。

ここに私の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
};

ツリーノードの「リスナー」:

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'
    }   }]
});

したがって、私の目的は、ノードをクリックしたときにコンテンツパネルのアイテムを変更することです。

助けてくれてありがとう!

4

1 に答える 1

2

それを試して、コメントで教えてください:

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!を閉じるための}がありません。

于 2011-05-30T16:09:42.027 に答える