2

シナリオ

アプリケーションのどこでも使用されている gridpanel (たとえばgrid ) があります。コンポーネント ( panel1およびpanel2 ) がgridを使用しているとします。このグリッドはストア ( store1 )を使用しています。グリッドを更新せずに panel1 のグリッドを更新したいpanel2 で

私の問題

panel1とpanel2 のグリッドに異なるストアを使用したくありません。これを達成できる方法はありますか。

ストア (新しいデータを含む) を panel1 のグリッドにバインドしようとしましたが、panel1 と panel2 の両方のグリッドが更新されています。

私が十分に明確でない場合は、お知らせください.これを解決するのを手伝ってください.どうもありがとう.

**For reference**
/*my grid*/
Ext.define('APP.view.mygrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.mygrid',
store:'store1',
columns: [ ...  ]


/*my panels*/
{
  xtype:'panel',
  items:[
         {
           xtype :'mygrid',
         }
       ],
  xtype:'panel',
  items:[
         {
           xtype :'mygrid',
         }
        ],
 }
4

3 に答える 3

0

グリッドが呼び出されるたびにストアのインスタンスを作成することでこれを解決しました。ご覧ください:

initComponent   : function() {
    this.items = [          
        {
            xtype   : 'myPanelgrids'
            name    : 'panel1' // this is the extra config to identify the grid in added in my panel1
        }

    ];
    this.callParent();
},
listeners: {
    render: function(){
        var store = Ext.create('Ext.data.Store', 
            {
                model: 'App.model.MyModel',
                autoLoad: true,
                 proxy: {
                        type: 'ajax',
                        url:'app/data/configdata.json',
                        reader: {
                            type: 'json',
                            root : 'myroot'//maintained a json property file with different roots for grids in panel1 and panel2
                        }
                    }
            }
        );

        this.down('grid').reconfigure(store);
    }
}

コントローラーから特定のグリッドのストアを更新しています。

于 2013-07-02T04:48:32.737 に答える
0

2 番目のパネルのストアを作成できるので、これを試してください。

var secondStore=Ext.create('your_store');
items: [
    {
        xtype: 'gridpanel',
        title: 'grid1',
        store: 'your_store'
    },{
        xtype: 'gridpanel',
        title: 'grid2',
        store: secondStore
    }
]
于 2013-06-30T08:13:00.190 に答える
0

ストア内のローカルの変更によってグリッドを更新し、Web サービスを呼び出さないと仮定します。次に、これを試すことができます:

store.suspendEvents(false); // false: do not queue events
// do some data changes now
store.resumeEvents();

grid.getView().refresh(); // only on the first grid
于 2013-06-30T18:57:07.447 に答える