服务接口提供的数据格式没办法直接使用,可通过实现reader.transform函数进行预处理
样例
Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url : 'users.json',
reader: {
type: 'json',
transform: {
fn: function(data) {
return data;
},
scope: this
}
}
},
});
源码解析
...
getResponseData: function(response) {
...
return Ext.decode(response.responseText);
...
}
...
...
read: function(response, readOptions) {
...
result = this.getResponseData(response);
...
data = this.readRecords(result, readOptions);
...
}
...
readRecords: function(data, readOptions, internalReadOptions) {
...
transform = me.getTransform();
if (transform) {
data = transform(data);
}
...
}
...