Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    Pilsen, Czech Republic
    Posts
    40
    Vote Rating
    0
    dherbolt is an unknown quantity at this point

      0  

    Default Ext.data.Store.loadData doesn't provide mapping of Model's fields

    Ext.data.Store.loadData doesn't provide mapping of Model's fields


    REQUIRED INFORMATION


    Ext version tested:
    • Ext 4.1 RC1

    Browser versions tested against:
    • All

    DOCTYPE tested against:
    • HTML 4.01 Strict

    Description:
    • Ext.data.Store.loadData doesn't provide mapping
    • If you have defined Model with mapping for fields, Reader should map field value from data object. But it is done only if data are defined in stores config (by data cfg option). If you want to load new data by Ext.data.Store.loadData, mapping is not done.

    Steps to reproduce the problem:
    • Use attached example
    • Grid contains two columns, the first with numbers and the second with letters
    • Click on button 'Load New Data'

    The result that was expected:
    • Data are reloaded
    • The first column still contains numbers and the second letters.

    The result that occurs instead:
    • Data are reloaded [OK]
    • The first col contains letters and the second contains numbers [BUG]

    Test Case:

    Code:
     Ext.require([
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.state.*'
    ]);
    
    Ext.define('MyModel', {
        extend: 'Ext.data.Model',
        fields: [
           {name: 'numbers', mapping: 1},
    	   {name: 'letters', mapping: 0}
        ],
        idProperty: 'numbers'
    });
    
    Ext.onReady(function() {
    
    
        // sample static data for the store
        var myData = [
    		['A', 0],
    		['B', 1],
    		['C', 2],
    		['D', 3],
    		['E', 4]
        ];
    
    	var myData2 = [
    		['F', 5],
    		['G', 6],
    		['H', 7],
    		['I', 8],
    		['J', 9]
    	];
    
        // create the data store
        var store = Ext.create('Ext.data.ArrayStore', {
            model: 'MyModel',
            data: myData
        });
    
        // create the Grid
        var grid = Ext.create('Ext.grid.Panel', {
            store: store,
            multiSelect: true,
            columns: [
                {
                    text     : 'Numbers',
                    flex     : 1,
                    dataIndex: 'numbers',
    				renderer: function (val) {
    					return Ext.isNumber(val) ? val : '<span style="color: red;">' + val + '</span>';
    				}
                },
                {
                    text     : 'Letters',
                    width    : 75,
                    dataIndex: 'letters',
    				renderer: function (val) {
    					return Ext.isString(val) ? val : '<span style="color: red;">' + val + '</span>';
    				}
                }
            ],
            height: 230,
            width: 250,
            renderTo: Ext.getBody(),
            viewConfig: {stripeRows: false},
    		bbar: {
    			xtype: 'toolbar',
    			items: {
    				text: 'Load New Data',
    				handler: function () {
    					grid.getStore().loadData(myData2);
    				}
    			}
    		}
        });
    });


    HELPFUL INFORMATION

    Debugging already done:
    • none

    Possible fix:
    • not provided

    Additional CSS used:
    • only default ext-all.css

    Operating System:
    • All

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,170
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This is by design. If you want it to go through the reader, use: http://docs.sencha.com/ext-js/4-0/#!...od-loadRawData
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1

Tags for this Thread