Results 1 to 5 of 5

Thread: Ext.data.ArrayReader.readRecords have a bug when mapping 'prop1.propNext'

  1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    8
    Vote Rating
    0
      0  

    Exclamation 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:
    Code:
        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'},//not any effect
    {name: 'order', mapping: 'userData.order'}//not any effect too

    ]);

    My fix:
    the right code is:
    var records = this.extractData(this.getRoot(o), true);
    Code:
    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
                };
            }
        });
    }

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,434
    Vote Rating
    859
      0  

    Default

    What does your data look like? Shouldn't you be using a JsonReader?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Apr 2010
    Posts
    8
    Vote Rating
    0
      0  

    Default

    please see Test Case,then run the Test Case,you will see 'info' and 'order' columns is nothing each!

    Then add fix code,run Test Case again,you will see 'info' and 'order' columns is good!

    I load datas with treepanel! when select a treenode, show children list in the gridpanel! so i call store.loadData(treeNode.attributes.children)!
    my data like this:

    var datas = [];
    for (var i = 0; i < 10; i++) {
    datas[i] = {id: i, text: 'text' + i, userData: {info: 'info' + i, order: i % 5}};
    }

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,434
    Vote Rating
    859
      0  

    Default

    You should be using a JsonReader, not an array reader. Moving to help.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Apr 2010
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •