PDA

View Full Version : Using Nested List with linked Models



Ayame
13 Mar 2011, 10:39 AM
Hi,

I'm trying to use a Nested List with a Treestore that gets info from a json feed on the same server. Everything works fine as long as I follow the vimeo example on nested lists, however that method of working has certain limitations imho.

I wanted to be able to address different fields for my list and detail items, so I thought I would solve it by creating two models instead of a single one and linking them with a hasMany association.
Unfortunately whatever I attempt, I cannot get it to work with the multiple models. Can someone tell me if this is possible or correct me if I'm doing something wrong?

The panel:

IMDB.views.CommunityPanel = Ext.extend(Ext.Panel, {
title: 'Community',
cls: 'tab community',
items: [
new Ext.NestedList({
fullscreen: true,
displayField: 'title',
store: IMDB.stores.communitystore,
title: 'Community list',
getDetailCard: function(item,parent){
detailCard = new Ext.Panel({
scroll: 'vertical',
tpl: '<h2>{title} {id} {latitude}</h2>'
});
detailCard.update(item.attributes.record.data);
this.backButton.setText(parent.attributes.record.data.title);
return detailCard;
}
})
]
});

The store:

IMDB.stores.communitystore = new Ext.data.TreeStore({
model: 'Community',
proxy: {
type: 'ajax',
url: '/json.php/CommunityService.getCommunitiesFullInfo/',
reader: {
type: 'tree',
root: 'communities'
}
}
});

The models:

Ext.regModel('Member',{
fields: [
{name: 'id', type: 'int'},
{name: 'community_id', type: 'int'},
{name: 'title', type: 'string'},
{name: 'latitude', type: 'double'},
{name: 'leaf', type: 'boolean'}

]
});
Ext.regModel('Community', {
fields: [{name: 'id', type: 'int'}, {name: 'title', type: 'string'}],
hasMany: {model: 'Member', name: 'members'}
});

regApp code was left out for simplicity.

Any help appreciated!

Ayame
14 Mar 2011, 9:32 AM
Can anyone (staff perhaps?) please have a look at this? Because if it's not possible, that's a serious flaw in the model part of the mvc architecture...

themaxx
26 May 2011, 8:08 AM
Did you solve this? I'm trying to do this too. I'd appreciate any info you have on this subject.

insnet
6 Dec 2011, 7:41 AM
I need help too

JavascriptParrot
14 Dec 2011, 12:26 PM
I have also this problem, but what I read is that nested list with linked models not supported by Touch 1.x:((

Edit: Maybe one off the staff can tell how we can do this?