3

Extjs アプリケーションでは、Grid とその上に Tabs 行があります。グリッドの内容は、選択したタブによって異なります。タブに Jan-Feb-Mar-... の値があるとします。タブをクリックすると、グリッドのストアがリロードされます

質問: 1 つの共有インスタンスを持つために、12 のグリッド コンポーネントの重複を避けることは可能ですか?

ありがとう

免責事項: sencha のフォーラム、Google、stackoverflow での検索は成功しませんでした :(

4

6 に答える 6

2

それはそうですが、それは価値がある以上の努力を必要とするでしょう. コンポーネントのプロトタイプを作成するだけで、新しいインスタンスを非常に迅速に作成できます。

于 2010-12-20T08:47:14.300 に答える
0

次の実装がニーズを満たしていることを願っています 1. カスタム グリッドを作成して登録します 2. タブ パネルに配置します

グリッドは xtype を使用して作成されるため、タブを変更しても 12 個のインスタンスは作成されません。

 Application.PersonnelGrid = Ext.extend(Ext.grid.GridPanel, {
         border:false
        ,initComponent:function() {
            Ext.apply(this, {
                 store:new Ext.data.Store({...})
                ,columns:[{...}, {...}]
                ,plugins:[...]
                ,viewConfig:{forceFit:true}
                ,tbar:[...]
                ,bbar:[...]
            });

            Application.PersonnelGrid.superclass.initComponent.apply(this, arguments);
        } // eo function initComponent

        ,onRender:function() {
            this.store.load();

            Application.PersonnelGrid.superclass.onRender.apply(this, arguments);
        } // eo function onRender
    });

    Ext.reg('personnelgrid', Application.PersonnelGrid);

    var panel = new Ext.TabPanel({
                    items:[{  
                            title:'Jan', 
                            items: [{xtype:'personnelgrid'}]
                          }, { 
                            title: 'Feb', 
                            items: [{xtype:'personnelgrid'}]
                          }
                          ....
                           {
                             title: 'Dec',
                             items: [{xtype:'personnelgrid'}] 
                           }] 
                  }) 
于 2010-12-30T14:16:10.017 に答える
0

私はこれを自分で試したことはありませんが、空のタブで TabPanel を作成し、タブ ストリップのみが表示されるように TabPanel のサイズを変更できると思います。その下に (適切なレイアウト、ボーダー、vbox などを使用して) GridPanel を作成し、TabPanel のactivateイベントを使用して、現在アクティブなタブに基づいてグリッドをリロードします。

于 2010-12-20T17:25:29.817 に答える
0

これを試して

    var gridJanName = Ext.create('Ext.grid.Panel', {
        enableColumnHide: false,
        autoScroll:true,
        store: storeJanNameGroup,
        border:true,
        stripeRows: true,
        columnLines:false,
        loadMask: true,
        tbar:tbgridTools,
        margin: '1 1 1 1',
        pageSize: 100,
        maxWidth:700,
        features: [groupFeature],
        selModel: {
            mode: 'MULTI'
        },
        columns: [
            {xtype:'rownumberer',width:50},
            {dataIndex:'id', hidden:true},
        //etc
        ]
    }); 
        var gridFebName = Ext.create('Ext.grid.Panel', {
        enableColumnHide: false,
        autoScroll:true,
        store: storeJanNameGroup,
        border:true,
        stripeRows: true,
        columnLines:false,
        loadMask: true,
        tbar:tbgridTools,
        margin: '1 1 1 1',
        pageSize: 100,
        maxWidth:700,
        features: [groupFeature],
        selModel: {
            mode: 'MULTI'
        },
        columns: [
            {xtype:'rownumberer',width:50},
            {dataIndex:'id', hidden:true},
        //etc
        ]
    });
    //
    //etc grid
    //


    var JanPanel = Ext.create('Ext.panel.Panel', {
        title:'Jan',
        bodyPadding: 5, 
        Width:780,
        layout: {
            type: 'hbox',
            align: 'stretch'
        },
        items: [gridJanName]
    });
    var FebPanel = Ext.create('Ext.panel.Panel', {
        title:'Feb',
        bodyPadding: 5, 
        Width:780,
        layout: {
            type: 'hbox',
            align: 'stretch'
        }
        //,items: [gridFebName]
    });
    var MarPanel = Ext.create('Ext.panel.Panel', {
        title:'Mar',
        bodyPadding: 5, 
        Width:780,
        layout: {
            type: 'hbox',
            align: 'stretch'
        }
        //,items: [gridMarName]
    });
    //etc
    var eachMonthstabs = Ext.create('Ext.tab.Panel', {
        minTabWidth: 130,
        tabWidth:150,
        //Width:750,
        scroll:false,
        autoHeight: true,
        id:'timestabs',
        enableTabScroll:true,
        items: [
            {
                xtype:JanPanel
            },
            {
                xtype:FebPanel
            },
            {
                xtype:MarPanel
            }
            ///etc
            ]
    });
于 2013-07-16T06:42:10.303 に答える