다음과 같은 저장소 구성으로 Grid 구성 요소를 만들었습니다.Extjs Restful Store, Batch에서 요청을 보내시겠습니까?
//Create the store
config.store = new Ext.data.Store({
restful: true,
autoSave: false,
batch: true,
writer: new Ext.data.JsonWriter({
encode: false
}),
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root: 'data',
fields: cfg.fields
}),
proxy: new Ext.data.HttpProxy({
url:cfg.rest,
listeners:{
exception: {
fn: function(proxy, type, action, options, response, arg) {
this.fireEvent('exception', proxy, type, action, options, response, arg);
},
scope: this
}
}
}),
remoteSort: true,
successProperty: 'success',
baseParams: {
start: 0,
limit: cfg.pageSize || 15
},
autoLoad: true,
listeners: {
load: {
fn: function() {
this.el.unmask();
},
scope: this
},
beforeload: {
fn: function() {
this.el.mask("Working");
},
scope: this
},
save: {
fn: function(store, batch, data) {
this.el.unmask();
this.fireEvent('save', store, batch, data);
},
scope: this
},
beforewrite: {
fn: function(){
this.el.mask("Working...");
},
scope: this
}
}
});
참고 : fireEvents를 무시하십시오. 이 저장소는 공유 사용자 지정 그리드 구성 요소에서 구성됩니다.
그러나 여기서 한 가지 문제가 있습니다. 내가 한 CRUD 작업이 무엇이든, 항상 선택한 N 개의 행과 동일한 N 개의 요청을 서버에 제공합니다. 즉, 10 개의 행을 선택하고 Delete 키를 누르면 10 개의 DELETE 요청이 서버에 전송됩니다.
예를 들어, 다음과 같이 레코드를 삭제하는 방법입니다.
/**
* Call this to delete selected items. No confirmation needed
*/
_deleteSelectedItems: function() {
var selections = this.getSelectionModel().getSelections();
if (selections.length > 0) {
this.store.remove(selections);
}
this.store.save();
this.store.reload();
},
참고 : "this"의 범위는 Grid Component입니다.
그래서, 그렇게 될까요? 또는 구성 문제가 있습니까? Extjs 3.3.1을 사용 중이며 Ext.data.Store,
아래의
batch
설명서에 따라 Store가 RESTful이면 DataProxy도 RESTful이며 각 레코드에 대해 고유 트랜잭션이 생성됩니다. .
이것이 나의 구성 문제가되기를 바랍니다.
참고 : listful
, encode
, writeAllFields
, encodeDelete
에서 Ext.data.JsonWriter
를 시도했습니다 ... 희망 없음
안녕하세요, 귀하의 답변에 많은 감사드립니다. 이것이 내가 적어도이 문제를 제기 한 구성 실수 중 하나라고 생각했습니다. 적어도 당신은 나와 확인해주었습니다. –
이것이 여전히 ExtJS 4.1.3에서 사실인지 궁금합니다. – justinzane
@justinzane - ExtJS 4에 대해 모르겠습니다.이 질문은 ExtJS 3에 관한 것입니다. v4 안정적인 일괄 요청에 대해 물어 보는 것은 가치가 있습니다. – wes