Ext.data.ArrayReader的bug

官方提交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
            };
        }
    });
}
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值