저장소에서 데이터를 가져 오는 레이블을 업데이트해야합니다. 전 가게에 새로운 데이터를로드해야합니다. 매 10 초. 간단합니다. setInternal()
(TaskRunner가 o_0 작업이 아니기 때문에) _을 사용하고 store.load 이벤트를 호출하십시오. 하지만 제 업무는 훨씬 더 구체적입니다. 두 개의 열이 포함 된 표가 있으며 저장소의 일부 데이터를 가져오고 일부 데이터는 사용자 지정입니다. 분명 저장소 dataindexes가있는 열 앞에 사용자 지정 문자열 데이터와 일부 숫자 데이터가있는 저장소에 몇 가지 새로운 레코드가 있음을 의미합니다. 단어로 설명하기가 어려울 수 있지만 코드에서 보입니다.extjs 4 동적 저장소
//---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') 인 그리드로 렌더링됩니다 ... 어디에 문제가 있습니까?
감사합니다 이해하기위한! 나는 문제가 어디에 있는지 이미 알았지 만, 나의 결정은 너무 우아하지 않았다 ... 나는 모든 다른 코드를 reload()에 넣었다. 하지만 지금 당신의 도움으로 나는 내 문제를 더 잘 해결할 수 있습니다! – Iexpmhihx