When I attempt to find a record in an ArrayStore using Sencha Touch 2, no records are returned.
store.findExact('Symbol', 'GOOG')
returns -1.
As shown in the screenshot below,
store.getRange()
returns 44 records, and
store.first()
returns a record, but
store.first().get('Ask')
returns undefined.
Additionally, when I do
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?
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:
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:
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:
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.