1

ストアからデータを取得するラベルを更新する必要があります。exの新しいデータをストアにロードする必要があります。10秒ごと。簡単です - setInternal()(TaskRunner は o_0 で動作しないため)_ を使用し、store.load イベントを呼び出します。しかし、私の仕事はもっと具体的です。また、2 つの列を含むグリッドもあり、ストアから一部のデータを取得し、一部のデータはカスタムです。これは、明確な store dataindexes を持つ列の前に、カスタム文字列データといくつかの数値データを含むストアにいくつかの新しいレコードがあることを意味します...言葉で説明するのは難しいかもしれませんが、コードでは次のようになります:

//---Store---
Ext.define('App.store.Data', {
    extend: 'Ext.data.Store',
    autoLoad: false,
    storeId:'Data',
    model: 'App.model.DataModel',
    proxy   : {
    type    : 'ajax',
    url: 'http://mybackend',
    reader: {
        type: 'json'
    } 
    },
    data:[first = true],
    listeners:{
        load: function()
        {
            if(first){
            first=false;
            myApp.getController('App.controller.Controller').StoreLoadHandler();
            setInterval(function (){myApp.getController('App.controller.Controller').StoreLoadHandler();},10000);
            }

        }
    }
});
//---Controller---
StoreLoadHandler: function(){
    var store = this.getStore('Data');
    //upload data from base into store
    store.reload(); 
    store.add(
            [
                {
                    fio: 'somedata',
                    //calculate some data and write it into store. All dataindexes are existsin model 
                    operCount: parseInt(this.getStore('Data').first().get('isQuick')),
                    opersvod: (this.getStore('Data').first().get('opersvod')),
                    isQuick:parseInt(this.getStore('Data').first().get('isQuick')),
                    ipk: (this.getStore('Data').first().get('ipk')),
                    allCount: (this.getStore('Data').first().get('allCount')),
                    id: 0
                },
                {
                    fio: 
                    ...
                    id: 1
                },
                {
                    fio: 
                    ...
                    id: 2
                }       
            ]
        );



       //takes my labels and use setText, works brilliant
    Ext.ComponentQuery.query('#TopPanel')[0].items.getAt(0).items.get('inW').setText(this.StoreCalc('iw'));
    Ext.ComponentQuery.query('#TopPanel')[0].items.getAt(1).items.get('isClose').setText(this.StoreCalc('isClose'));
    Ext.ComponentQuery.query('#TopPanel')[0].items.getAt(2).items.get('denied').setText(this.StoreCalc('denied'));
    Ext.ComponentQuery.query('#BottomPanel')[0].items.getAt(0).items.get('allCount').setText(store.getAt(3).get('allCount'));

    //use sort
    store.sort([
    {
        property : 'id',
        direction: 'ASC'
    },
    {
        property : 'fio',
        direction: 'ASK'//'DESC'
    }
    ]);
    store.destroy();
    }

この場合、store.load()メソッドを呼び出すと、store.reload()ストア内のカスタム レコードが失われます。この操作をリストから削除すると、カスタム データが保存され、2 列のグリッドにレンダリングされます (dataindexes は「fio」と「operCount」です)... どこに問題がありますか?

4

1 に答える 1

1

addストアにデータがない状態でメソッドを呼び出しているようです。reloadメソッドのコールバック オプションを使用します。

store.reload({callback: function() {
          store.add(...);
  } 
})

注: メソッドからリロード タイマーを構成しないでください。load理解に苦しむことになります。

于 2013-04-09T10:35:47.443 に答える