1
Extjs 4.2에 그리드가 있는데 그 저장소는 아래와 같이 구성됩니다.Extjs 4.2 그리드 새로 고침이 이전 데이터를로드합니다.
var userStore = Ext.create('Ext.data.JsonStore', {
model: 'User',
proxy: {
type: 'ajax',
api: {
create: '/pwbench/form/products/fctrmgmt/data.json',
read: '/pwbench/form/products/fctrmgmt/data.json',
update: '/pwbench/form/products/fctrmgmt/data.json',
destroy: '/pwbench/form/products/fctrmgmt/data.json'
},
reader: {
type: 'json'
},
writer: {
type: 'json'
}
},
autoLoad: true
});
그리드 안의 저장을 클릭하면 다음과 같이 구성됩니다.
handler: function() {
var recordsArray = new Array();
var dataRecords = new Array();
recordsArray = grid.getStore().data.items;
for (var i = 0; i < recordsArray.length; i++) {
console.log(recordsArray[i].data);
dataRecords.push(Ext.encode(recordsArray[i].data));
}
console.log(dataRecords.length);
Ext.Ajax.request({
url: 'mainpage.jsp',
params: {
records: dataRecords
},
success: function(response){
var text = response.responseText;
console.log(text);
userStore.sync();
userStore.load();
}
});
}
나는 아약스 요청에 의해 전송 된 데이터를 읽을 수있는 자바 클래스가 다음 나는 가게가 데이터를 가져 오기 위해 사용하는 data.json 파일을 덮어 씁니다. json 파일을 아무런 문제없이 덮어 씁니다. 그러나 문제는 동기화 후 userStore.load()를 호출 할 때 변경하기 전에 이전 데이터를 표시한다는 것입니다. 그리드를 새로 고치거나 전체 페이지를 새로 고치는 경우에도 Eclipse에서 전체 프로젝트를 새로 고치고 페이지를 다시로드 할 때만 이전 데이터를 표시 한 다음 새 덮어 쓰기 된 데이터를 표시합니다.
캐시에 문제가 있습니까? 누군가가 문제를 말해 줄 수 있습니까?
의 성공 콜백에 부하를 넣어해야합니다. 구문은 this.get입니다. Store(). sync(); 그것은 도움이 될 것입니다. –
Hariharan
이를 위해 상점에 ID를 추가해야합니까? 예, this.get ('Storeid') Store(). sync? 나는 성공 함수 안에 this.getStore(). sync()를 사용해 보았습니다. getStore가 객체에 정의되어 있지 않다는 오류가 발생했습니다. –
안녕하세요 사용자 2380798 참조 sencha 예제, 당신은 이해할 수 있습니다. http://docs.sencha.com/extjs/4.2.0/#!/guide/application_architecture storeid가 필요하지 않습니다. 상점 이름이 필요합니다. – Hariharan