PDA

View Full Version : ArrayStore Issue



taylon
8 Jul 2010, 12:06 PM
Hello there. I'm hoping this is an easy fix. I'm currently trying to set up an ArrayStore but if I don't use some sort of Proxy (session or local storage) I receive the following error:

Uncaught Error: The 'memory' type has not been registered with this manager

Currently I'm just using the List example, but trying to convert it to use an array I'm pulling elsewhere instead of hardcoding like the example does.

Incidently if I do use some sort of Proxy I get the below message which I've tracked down to the fact that it appears that "loadData" doesn't appear to be using my model so my field is blank and my data in the debugger looks like

0: "Fred Flintston"
address:

Uncaught TypeError: Cannot call method 'toLowerCase' of undefined
ext-touch-debug.js:15012

Any pointers for ArrayStore would be much appreciated. Full code with a Proxy below.




var myData = [
['Fred Flintstone'],
['Barney Rubble']
];

Ext.regModel('Contact', {
fields: ['address']
});


demos.ListStore = new Ext.data.ArrayStore({
proxy: new Ext.data.SessionStorageProxy({
id: 'myProxy'
}),
fields: ['address'],
idIndex: 0,
storeId: 'MyStore',
model: 'Contact',
data: myData
});

demos.ListStore.loadData(myData);

demos.List = new Ext.Panel({
layout: Ext.platform.isPhone ? 'fit' : {
type: 'vbox',
align: 'center',
pack: 'center'
},
cls: 'demo-list',
items: [{
width: 300,
height: 500,
xtype: 'list',
store: demos.ListStore,
tpl: '<tpl for="."><div class="contact"><strong>{address}</strong></div></tpl>',
itemSelector: 'div.contact',
singleSelect: true,
grouped: false,
indexBar: true
}]
});

tfrugia
12 Jul 2010, 11:20 AM
You need to define the grouping on your store. Here is a quick snippet:



demos.ListStore = new Ext.data.ArrayStore({
getGroupString : function(record) {
// return the first character of the address
return record.get('address')[0];
},
proxy: new Ext.data.SessionStorageProxy({
id: 'myProxy'
}),
fields: ['address'],
idIndex: 0,
storeId: 'MyStore',
model: 'Contact',
data: myData
});

taylon
12 Jul 2010, 11:39 AM
Thanks for taking the time to look at it. I thought I had tried that and even set my "grouped" to false so that it wasn't sorted in any particular way.

What I'm finding is that the model fields just aren't being populated for me. I'm pulling my actual array from the Google Datastore and just passing it in as is (I'll work on the actual sorting later). Currently my work around is to use the index fields instead of the model fields. So if you looked in debugger array 0 values might look like:

0: Some text here
1: more text here
2: yet even more text
field1:
field2:
field3:

Instead of using {field1}, {field2}, {field3] I'm using {0}, {1}, {2} because that's where my data is actually sitting.

Anyway thanks again for taking the time to look at it. I see lots of list threads popping up so at least I don't feel too bad for not figuring this out right away.

su27
13 Jul 2010, 7:52 AM
i have the same issue. this bug is caused by the memory proxy hasn't been registered.
add this line at the end of MemoryProxy.js can fix it.
Ext.data.ProxyMgr.registerType('memory', Ext.data.MemoryProxy);

taylon
13 Jul 2010, 8:13 AM
Thank you very much. That worked perfectly for the proxy issue.

evant
13 Jul 2010, 8:14 AM
I ran into this the other day. It's been updated for the next release. Nice catch.