Javascript-форум (https://javascript.ru/forum/)
-   ExtJS (https://javascript.ru/forum/extjs/)
-   -   Как создавать вкладки для Tab Panel в ExtJS 4 (https://javascript.ru/forum/extjs/23423-kak-sozdavat-vkladki-dlya-tab-panel-v-extjs-4-a.html)

Bkmz_1_ 22.11.2011 22:43

Как создавать вкладки для Tab Panel в ExtJS 4
 
В ExtJS 3 я это делал так

// Новая вкладка
    new Ext.getCmp('content').add({
        title: 'Город ' + CityName,
        closable: true,
        xtype: 'form',
        items: [{
            layout: 'column',
            border: false,
            items:[{
                columnWidth: 0.5,
                layout: 'form',
                border: false,
                bodyStyle: 'padding:10px',
                items: [ TableGoods ]
            },{
                columnWidth: 0.5,
                layout: 'form',
                border: false,
                bodyStyle: 'padding:10px',
                items: [ TableService ]
            }]
        }]
    }).show();


А как мне это сделать в ExtJS 4 который построен на mvc

Я делаю так:

Ext.define('MyApp.controller.Wrapper', {
    extend: 'Ext.app.Controller',

    init: function() {
       this.control({
		'#button-select-city': {
                click: this.onGroups
            }
        });
    },

    onGroups: function() {
        this.getComponent('content').add({
            title: 'Город',
            closable: true,
            xtype: 'form',
            items: [{
               // наш шаблончик, чтобы xtype его видел в шаблончике надо задать параметр alias : 'widget.tab-groups'
               xtype: 'tab-groups'
            }]
       }).show();
    }    

});

Шаблончик view который надо вставить приклике на кнопку.

Ext.define('MyApp.view.tab-groups', {
    extend: 'Ext.panel.Panel',
    alias : 'widget.tab-groups',
    layout: 'column',
    border: 0,
    initComponent: function() {
        this.items = [
            {
                xtype: 'gridpanel',
                itemId: 'grid-goods',
                padding: '10px 5px 10px 10px',
                title: 'Товары',
                store: 'Good',
                columnWidth: 0.5,
                columns: [
                    {
                        dataIndex: 'name',
                        flex: 1,
                        text: 'Товары'
                    },
                    {
                        width: 50,
                        dataIndex: 'count',
                        text: '№'
                    }
                ]
            },
            {
                xtype: 'gridpanel',
                itemId: 'grid-services',
                padding: '10px 10px 10px 5px',
                title: 'Услуги',
                store: 'Service',
                columnWidth: 0.5,
                height: 585,
                columns: [
                    {
                        dataIndex: 'name',
                        flex: 1,
                        text: 'Услуги'
                    },
                    {
                        width: 50,
                        dataIndex: 'count',
                        text: '№'
                    }
                ]
            }
        ];
        this.callParent(arguments);
    }
});


Как мне эти два файлика привентить?

Bkmz_1_ 02.12.2011 03:57

Надо было просто подключить view-шку

views: [
    'tab-groups'
],


Вот здесь
Ext.define('MyApp.controller.Wrapper', {
    extend: 'Ext.app.Controller',

    views: [
        'tab-groups'
    ],

    init: function() {
       this.control({
		'#button-select-city': {
                click: this.onGroups
            }
        });
    },

    onGroups: function() {
        this.getComponent('content').add({
            title: 'Город',
            closable: true,
            xtype: 'form',
            items: [{
               // наш шаблончик, чтобы xtype его видел в шаблончике надо задать параметр alias : 'widget.tab-groups'
               xtype: 'tab-groups'
            }]
       }).show();
    }    

});


Часовой пояс GMT +3, время: 10:04.