PDA

View Full Version : Ext.data.proxy.Memory Errors



bweiler
3 Dec 2011, 5:19 PM
I really like 2.0 so far, but I'm stuck getting a simple list to work. The following code is taken directly from the List code in the 2.0 Kitchen Sink example with a few minor tweeks to get it working independently.

Here's the error I'm getting:

TypeError: 'undefined' is not a valid argument for 'instanceof' (evaluating 'proxy instanceof Ext.data.proxy.Memory')

It seems to be a problem with the static data in the store. Any help will be appreciated.

Thanks





Ext.application({
name: 'Test'
});


// Changed Ext.regModel to Ext.define
Ext.define('Contact', {
extend: 'Ext.data.Model',
fields: ['firstName', 'lastName']
});


Ext.create('Ext.data.Store', {
id: 'ListStore',
model: 'Contact',
sorters: 'firstName',
getGroupString : function(record) {
return record.get('firstName')[0];
},
data: [
{firstName: 'Julio', lastName: 'Benesh'},
{firstName: 'Julio', lastName: 'Minich'},
{firstName: 'Tania', lastName: 'Ricco'},
{firstName: 'Odessa', lastName: 'Steuck'},
{firstName: 'Nelson', lastName: 'Raber'},
{firstName: 'Tyrone', lastName: 'Scannell'},
{firstName: 'Allan', lastName: 'Disbrow'},
{firstName: 'Cody', lastName: 'Herrell'},
{firstName: 'Julio', lastName: 'Burgoyne'},
{firstName: 'Jessie', lastName: 'Boedeker'},
{firstName: 'Allan', lastName: 'Leyendecker'},
{firstName: 'Javier', lastName: 'Lockley'},
{firstName: 'Guy', lastName: 'Reasor'},
{firstName: 'Jamie', lastName: 'Brummer'},
{firstName: 'Jessie', lastName: 'Casa'},
{firstName: 'Marcie', lastName: 'Ricca'},
{firstName: 'Gay', lastName: 'Lamoureaux'},
{firstName: 'Althea', lastName: 'Sturtz'},
{firstName: 'Kenya', lastName: 'Morocco'},
{firstName: 'Rae', lastName: 'Pasquariello'},
{firstName: 'Ted', lastName: 'Abundis'},
{firstName: 'Jessie', lastName: 'Schacherer'},
{firstName: 'Jamie', lastName: 'Gleaves'},
{firstName: 'Hillary', lastName: 'Spiva'},
{firstName: 'Elinor', lastName: 'Rockefeller'},
{firstName: 'Dona', lastName: 'Clauss'},
{firstName: 'Ashlee', lastName: 'Kennerly'},
{firstName: 'Alana', lastName: 'Wiersma'},
{firstName: 'Kelly', lastName: 'Holdman'},
{firstName: 'Mathew', lastName: 'Lofthouse'},
{firstName: 'Dona', lastName: 'Tatman'},
{firstName: 'Clayton', lastName: 'Clear'},
{firstName: 'Rosalinda', lastName: 'Urman'},
{firstName: 'Cody', lastName: 'Sayler'},
{firstName: 'Odessa', lastName: 'Averitt'},
{firstName: 'Ted', lastName: 'Poage'},
{firstName: 'Penelope', lastName: 'Gayer'},
{firstName: 'Katy', lastName: 'Bluford'},
{firstName: 'Kelly', lastName: 'Mchargue'},
{firstName: 'Kathrine', lastName: 'Gustavson'},
{firstName: 'Kelly', lastName: 'Hartson'},
{firstName: 'Carlene', lastName: 'Summitt'},
{firstName: 'Kathrine', lastName: 'Vrabel'},
{firstName: 'Roxie', lastName: 'Mcconn'},
{firstName: 'Margery', lastName: 'Pullman'},
{firstName: 'Avis', lastName: 'Bueche'},
{firstName: 'Esmeralda', lastName: 'Katzer'},
{firstName: 'Tania', lastName: 'Belmonte'},
{firstName: 'Malinda', lastName: 'Kwak'},
{firstName: 'Tanisha', lastName: 'Jobin'},
{firstName: 'Kelly', lastName: 'Dziedzic'},
{firstName: 'Darren', lastName: 'Devalle'},
{firstName: 'Julio', lastName: 'Buchannon'},
{firstName: 'Darren', lastName: 'Schreier'},
{firstName: 'Jamie', lastName: 'Pollman'},
{firstName: 'Karina', lastName: 'Pompey'},
{firstName: 'Hugh', lastName: 'Snover'},
{firstName: 'Zebra', lastName: 'Evilias'}
]
});


Ext.define('Kitchensink.view.List', {
extend: 'Ext.tab.Panel',
config: {
activeItem: 2,
tabBar: {
docked: 'top',
layout: {
pack: 'center'
}
},
items: [{
title: 'Simple',
layout: Ext.os.deviceType == 'Phone' ? 'fit' : {
type: 'vbox',
align: 'center',
pack: 'center'
},
cls: 'demo-list',
items: [{
width: Ext.os.deviceType == 'Phone' ? null : 300,
height: Ext.os.deviceType == 'Phone' ? null : 500,
xtype: 'list',
store: 'ListStore',
itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}</div>'
}]
}, {
title: 'Grouped',
layout: Ext.os.deviceType == 'Phone' ? 'fit' : {
type: 'vbox',
align: 'center',
pack: 'center'
},
cls: 'demo-list',
items: [{
width: Ext.os.deviceType == 'Phone' ? null : 300,
height: Ext.os.deviceType == 'Phone' ? null : 500,
xtype: 'list',
store: 'ListStore',
itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}</div>',
grouped: true,
indexBar: true
}]
}, {
title: 'Disclosure',
layout: Ext.os.deviceType == 'Phone' ? 'fit' : {
type: 'vbox',
align: 'center',
pack: 'center'
},
cls: 'demo-list',
items: [{
width: Ext.os.deviceType == 'Phone' ? null : 300,
height: Ext.os.deviceType == 'Phone' ? null : 500,
xtype: 'list',
onItemDisclosure: function(record, btn, index) {
Ext.Msg.alert('Tap', 'Disclose more info for ' + record.get('firstName'), Ext.emptyFn);
},
store: 'ListStore', //getRange(0, 9),
itemTpl: '<div class="contact"><strong>{firstName}</strong> {lastName}</div>'
}]
}]
}
});


// Added call to show the list.
Ext.create('Kitchensink.view.List').show();

rdougan
3 Dec 2011, 5:24 PM
Which ST file are you using from the SDK? sencha-touch.js? Try using the sencha-touch-all-debug.js file from the SDK instead.

bweiler
4 Dec 2011, 8:28 AM
I'm using sencha-touch-debug.js, so I'll try sencha-touch-all-debug.js and see if it helps with debugging. However, this looks like a bug to me. With 1.x I didn't need to explicitly create a proxy to read inline data.

Here's the workaround I'm using for now:




Ext.create('Ext.data.Store', {
id: 'ListStore',
model: 'Contact',
sorters: 'firstName',
getGroupString : function(record) {
return record.get('firstName')[0];
},


data: [
{firstName: 'Julio', lastName: 'Benesh'},
{firstName: 'Julio', lastName: 'Minich'},
{firstName: 'Tania', lastName: 'Ricco'},
{firstName: 'Odessa', lastName: 'Steuck'},
...
],


// 2.0 Workaround to load data
proxy: {
type: 'memory',
reader: {
type: 'json',
root: this.data
}
}
});