-
8 Jan 2013 12:58 PM #1
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.
returns -1.Code:store.findExact('Symbol', 'GOOG')
As shown in the screenshot below,
returns 44 records, andCode:store.getRange()
returns a record, butCode:store.first()
returns undefined.Code:store.first().get('Ask')
Additionally, when I do
I get an object only containing the field 'id: "ext-record-2"'.Code:store.getAt(1).getData()
Why can I not retrieve records using store.findExact(), and why does record.get('column') return undefined?
screenshot.png
-
8 Jan 2013 2:29 PM #2
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:
Sencha Touch: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'} ] });
A workaround: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'} ] } });
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);
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote