ajax proxy 에서 extraData를 재정의 해서 처리하면된다.
json값은 아래와같다
{"list":[{"d:\\movie\\1 (2).jpg"},{"d:\\movie\\1.jpg"}],"totalCount":2,"success":true}
id value값으로 이루어져야하는데 위와같은 경우가 생길경우.. 모델에 매핑을 어떻게 해야할지모르겠다.
Model에 path라는 변수가 있기때문에
record.data.path부분에 위의 값을 넣어버린다..
그럼 된다-_-;;;;;;; 이짓을 할필요가 있을까싶지만...ㅋㅋ
new Ext.data.AjaxProxy({
type : 'ajax',
url : '/fileList.json',
contentType : 'application/json; charset=utf-8',
reader : {
type : 'json',
totalProperty : 'totalCount',
successProperty : 'success',
root : 'fileList',
extractData : function(root, returnRecords) {
var values = [],
records = [],
Model = this.model,
length = root.length,
idProp = this.idProperty,
node, id, record, i;
for (i = 0; i < length; i++) {
node = root[i];
values = this.extractValues(node);
id = this.getId(node);
if (returnRecords === true) {
record = new Model(values, id);
record.data.path = node;
record.raw = node;
records.push(record);
if (this.implicitIncludes) {
this.readAssociated(record, node);
}
} else {
values[idProp] = id;
records.push(values);
}
}
return records;
}
}
})
댓글을 달아 주세요