官方提交bug详情:Ext.data.ArrayReader.readRecords have a bug when mapping 'prop1.propNext'
* Ext 3.2.0
Adapter used:
* ext
css used:
* only default ext-all.css
Browser versions tested against:
* FF3 (firebug installed)
Operating System:
* ubuntu 9.10 64bit
Description:
* Ext.data.ArrayReader.readRecords have a bug when mapping 'prop1.propNext'
Test Case:
var record = Ext.data.Record.create([
{name: 'id', mapping: 'id'},
{name: 'name', mapping: 'text'},
{name: 'info', mapping: 'userData.info'},
{name: 'order', mapping: 'userData.order'}
]);
var store = new Ext.data.Store({sortInfo: {field: 'order'}, reader: new Ext.data.ArrayReader({id: 'id'}, record)})
var win = new Ext.Window({
closable: false,
layout: 'fit',
width: 700, height: 400,
items: [{
xtype: 'grid', title: ' ', iconCls: 'x-tree-node-icon-folder',
tbar: ['-', {text: 'refresh'}, '-', '->'],
columns: [
{header: 'ID', dataIndex: 'id', menuDisabled: true, hidden: true, width: 40, sortable: true, align: 'right'},
{header: 'name', dataIndex: 'name', hideable: false, width: 80, sortable: true},
{header: 'info', dataIndex: 'info', width: 100, sortable: true},
{header: 'order', dataIndex: 'order', width: 40, sortable: true, menuDisabled: true}
],
store: store
}]
});
win.show();
var datas = [];
for (var i = 0; i < 10; i++) {
datas[i] = {id: i, text: 'text' + i, userData: {info: 'info' + i, order: i % 5}};
}
store.loadData(datas);
var record = Ext.data.Record.create([
{name: 'id', mapping: 'id'},
{name: 'name', mapping: 'text'},
{name: 'info', mapping: 'userData.info'},//根据mapping的定义是支持这样映射的
{name: 'order', mapping: 'userData.order'}//not any effect too
]);
My fix:
the right code is:
var records = this.extractData(this.getRoot(o), true);
if (Ext.version == '3.2.0') {
Ext.apply(Ext.data.ArrayReader.prototype, {
readRecords : function(o){
this.arrayData = o;
var s = this.meta, success = true, v;
var records = this.extractData(this.getRoot(o), true);
var totalRecords = records.length;
if(s.totalProperty) {
v = parseInt(this.getTotal(o), 10);
if(!isNaN(v)) {
totalRecords = v;
}
}
if(s.successProperty){
v = this.getSuccess(o);
if(v === false || v === 'false'){
success = false;
}
}
return {
success : success,
records : records,
totalRecords : totalRecords
};
}
});
}
分享到:
相关推荐
`reader`则使用了`Ext.data.ArrayReader`,用于将数据解析成`PersonRecord`实例。 #### 三、数据转换 在创建完`Ext.data.Store`实例后,执行`store.load()`方法会触发数据转换的过程。`MemoryProxy`从内存中读取...
31、Ext.data.DataReader类 ……………26 32、Ext.data.ArrayReader类 …………… 26 33、Ext.data.JsonReader类 …………… 26 34、Ext.data.XmlReader类 …………… 27 35、Ext.data.Store类 …………………… 28 ...
31、Ext.data.DataReader类 ……………26 32、Ext.data.ArrayReader类 …………… 26 33、Ext.data.JsonReader类 …………… 26 34、Ext.data.XmlReader类 …………… 27 35、Ext.data.Store类 …………………… 28 ...
29. **Ext.data.ArrayReader类**、**JsonReader类**和**XmlReader类**:不同数据格式(数组、JSON、XML)的特定数据读取器。 30. **Ext.data.Store类**:数据存储,管理数据集,与DataProxy和DataReader交互。 31....
reader: new Ext.data.ArrayReader({}, [ { name: 'id' }, { name: 'name' }, { name: 'sex' }, { name: 'date', type: 'date', dateFormat: 'Y-m-d' }, { name: 'address' }, { name: 'tel' } ]) }); ``` ...
然后,创建一个`Ext.data.Store`实例,并设置`reader`为`ArrayReader`,这样我们就可以解析从服务器返回的数组数据。在成功获取数据后,使用`Ext.Ajax.request`方法将数据存储到`PagingMemoryProxy`中,如下所示: ...
13.6.2 Ext.data.ArrayReader 13.6.3 Ext.data.JsonReader 13.6.4 Ext.data.XmlReader 13.7 Ext.ux.DWR 13.7.1 Ext.data.DwrProxy 13.7.2 Ext.data.DWRTreeLoader 13.7.4 Web服务端配置 13.7.5 服务层接口 ...
13.6.2 Ext.data.ArrayReader 13.6.3 Ext.data.JsonReader 13.6.4 Ext.data.XmlReader 13.7 Ext.ux.DWR 13.7.1 Ext.data.DwrProxy 13.7.2 Ext.data.DWRTreeLoader 13.7.4 Web服务端配置 13.7.5 服务层接口 ...
7.3 Ext.data.Record 198 7.4 ArrayReader、JsonReader和XmlReader 199 7.4.1 JsonReader 200 7.4.2 ArrayReader 200 7.4.3 XmlReader 201 7.5 Store的加载数据 201 7.6 Store的数据操作 203 7.6.1 添加数据 203 ...
10.6.1 ArrayReader.........................241 10.6.2 JsonReader ...........................242 10.6.3 XmlReader..............................243 10.7 高级store...........................................
reader: new Ext.data.ArrayReader({}, [ {name: 'id', mapping: 0}, {name: 'sex', mapping: 1}, {name: 'name', mapping: 2}, {name: 'descn', mapping: 3} ]) }); // 初始化数据 ds.load(); // 创建 Grid...
reader: new Ext.data.ArrayReader({}, [ {name: 'id', mapping: 0}, {name: 'sex', mapping: 1}, {name: 'name', mapping: 2}, {name: 'descn', mapping: 3} ]) }); ds.load(); ``` 在GridPanel的配置中,...
reader: new Ext.data.ArrayReader({}, [ {name: 'id', mapping: 0}, {name: 'sex', mapping: 1}, // 映射其他字段... ]) }); ``` `load()`方法用于初始化数据加载。 3. **渲染GridPanel**:最后,使用`...
31. ArrayReader: added IDProperty and IDIndex (instead of ReaderID) 32. Renamed StoreResponseData class .TotalCount property to .Total. 33. Renamed StoreRefreshDataEventArgs class .TotalCount ...
reader: new Ext.data.ArrayReader({}, [ {name: 'id', mapping: 0}, {name: 'sex', mapping: 1}, {name: 'name', mapping: 2}, {name: 'descn', mapping: 3} ]) }); ds.load(); ``` 这里的MemoryProxy是内存...
proxy: new Ext.data.DWRProxy('YourDWRMethod'), // 使用DWR方法作为数据源 reader: new Ext.data.JsonReader({ totalProperty: 'total', // DWR返回的总记录数字段 root: 'data', // 数据集字段 idProperty: ...