Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    49
    Vote Rating
    0
    chaddjohnson is on a distinguished road

      0  

    Default Cannot get store record field value in Sencha Touch

    Cannot get store record field value in Sencha Touch


    When I attempt to find a record in an ArrayStore using Sencha Touch 2, no records are returned.

    Code:
    store.findExact('Symbol', 'GOOG')
    returns -1.

    As shown in the screenshot below,

    Code:
    store.getRange()
    returns 44 records, and

    Code:
    store.first()
    returns a record, but

    Code:
    store.first().get('Ask')
    returns undefined.

    Additionally, when I do

    Code:
    store.getAt(1).getData()
    I get an object only containing the field 'id: "ext-record-2"'.

    Why can I not retrieve records using store.findExact(), and why does record.get('column') return undefined?

    screenshot.png

  2. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    49
    Vote Rating
    0
    chaddjohnson is on a distinguished road

      0  

    Default


    Found the problem...

    I was trying to reuse a model across ExtJS and Sencha Touch applications. Sencha Touch expects "fields" to be defined inside "config," whereas ExtJS does not.

    ExtJS:

    Code:
    Ext.define('MyModel', {
      extend: 'Ext.data.Model',
      fields: [
        {name: 'Symbol',    type: 'string'},
        {name: 'LastPrice', type: 'float'},
        {name: 'Bid',       type: 'float'},
        {name: 'Ask',       type: 'float'},
        {name: 'Volume',    type: 'int'},
        {name: 'Close',     type: 'float'}
      ]
    });
    Sencha Touch:

    Code:
    Ext.define('MyModel', {
      extend: 'Ext.data.Model',
      config: {
        fields: [
          {name: 'Symbol',    type: 'string'},
          {name: 'LastPrice', type: 'float'},
          {name: 'Bid',       type: 'float'},
          {name: 'Ask',       type: 'float'},
          {name: 'Volume',    type: 'int'},
          {name: 'Close',     type: 'float'}
        ]
      }
    });
    A workaround:

    Code:
    var myModelConfig = {
      extend: 'Ext.data.Model',
      config: {
        fields: [
          {name: 'Symbol',    type: 'string'},
          {name: 'LastPrice', type: 'float'},
          {name: 'Bid',       type: 'float'},
          {name: 'Ask',       type: 'float'},
          {name: 'Volume',    type: 'int'},
          {name: 'Close',     type: 'float'}
        ]
      }
    };
    myModelConfig.fields = myModelConfig.config.fields;
    Ext.define('MyModel', myModelConfig);