PDA

View Full Version : data.Store Questions



tmtrademark
23 Jun 2010, 4:01 PM
Greetings. I am LOVING sencha touch and the opportunities it presents.

I am having some issues working with the data.Store / Model architecture.

At the most basic, I am trying to save user data from a form, save it locally, then be able to recall it.

This is what I thought my basic structure would look like:

[ [user1], [user2], [user3] ], where user1-3 are arrays containing the form data.

I created a class, each of which has it's own data store that holds the form data, then I insert the object into another data store.

I finally got this working how I want, but the way I have to access different data seems kind of ludicrous.

For instance, if I wanted to get user1's name from the array above i would have to do:


charStore.data.items[0].data.charData.data.map.name

charStore is the dataStore where the users live, and charData is the individual store inside each object that holds the stats.

I've made two model types, one for the form data and one for the users themselves. I'm pretty sure I have the form data one right, but the user one is a little trickier:


Ext.regModel('Character', {
fields: [
// {name: 'name', type: 'string'},
// {name: 'id', type: 'int'},
{name: 'character', type: 'object'});
]

Namely, I'm not sure if you can have a type of object.

I feel like I am doing this TOTALLY wrong. Can someone help? I've been going off of the forms and Solitaire examples so far.

Thanks!:">

meyerovb
23 Jul 2010, 4:11 AM
See the documentation for Ext.data.Types for instructions on how to create your own data type. You may be able to use AUTO (I'm not sure), but it would be best to have your own defined data type.