Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    10
    Vote Rating
    0
    erikras is on a distinguished road

      0  

    Default ArrayStore data problem in 4.1

    ArrayStore data problem in 4.1


    I've got my Model, which defines fields ['firstName', 'lastName', 'age'], and my ArrayStore that sets the data as [['Bob', 'Johnson',23], ['Alice', 'Smith', 55]], and I'm getting objects that look like:

    { firstName: 'Johnson', lastName: '23', age: undefined }
    { firstName: 'Smith', lastName: '55', age: undefined }

    There's clearly some index problem. In a loop somewhere.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    See if the following works for you:

    Code:
    Ext.create('Ext.data.Store', {
        storeId:'myStore',
        fields:['firstName', 'lastName', 'age'],
        data:{'items':[
            { 'firstName': 'Bob',  'lastName':'Johnson', 'age':23 },
            { 'firstName': 'Alice', 'lastName':'Smith', 'age':55 }
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    Ext.create('Ext.grid.Panel', {
        title: 'Names',
        store: Ext.data.StoreManager.lookup('myStore'),
        columns: [
            { header: 'firstName',  dataIndex: 'firstName' },
            { header: 'lastName', dataIndex: 'lastName', flex: 1 },
            { header: 'age', dataIndex: 'age', type: 'int' }
        ],
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });
    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    10
    Vote Rating
    0
    erikras is on a distinguished road

      0  

    Default


    Yes, that works, and I can't get it to break by switching it to an array reader or an ArrayStore.

    I'll have to examine my complex scenario – which was working in 4.0 – a little further.

    Thanks.

  4. #4
    Sencha User
    Join Date
    Mar 2010
    Posts
    10
    Vote Rating
    0
    erikras is on a distinguished road

      0  

    Default REPLICATED!

    REPLICATED!


    I figured it out. Not the fix, but how to replicate it. It only breaks when the model in the store does not directly extend Ext.data.Model, but extends an intermediary type.

    You can see it in action here.

    Code included below.

    Code:
    Ext.define('myapp.data.Model', {
                extend:'Ext.data.Model',
                constructor:function (config)
                {
                    this.callParent(arguments);
                }
            });
    Ext.define('myapp.model.Person', {
                extend:'myapp.data.Model',
                alternateClassName:['Person'],
                idProperty:'name',
                fields:[
                    { name:'firstName', type:'string' },
                    { name:'lastName', type:'string' },
                    { name:'age', type:'int' }
                ]
            });
    Ext.define('myapp.store.Person',
                       {
                           extend:'Ext.data.ArrayStore',
                           model:'myapp.model.Person',
                           storeId:'Person',
                           data:[
                               ['Alex', 'Bridgestone', 45],
                               ['Brenda', 'Carson', 34],
                               ['Dan', 'Epstein', 34]
                           ]
                       }
            );
    Ext.create('myapp.store.Person');
    Ext.onReady(function ()
                        {
                            Ext.create('Ext.container.Viewport', {
                                layout:'fit',
                                items:[
                                    {
                                        xtype:'grid',
                                        title:'Awesome People',
                                        store:'Person',
                                        columns:[
                                            { header:'First Name', dataIndex:'firstName' },
                                            { header:'Last Name', dataIndex:'lastName', flex:1 },
                                            { header:'Age', dataIndex:'age' }
                                        ]
                                    }
                                ]
                            });
                        });

Thread Participants: 1

Tags for this Thread