PDA

View Full Version : Ext.Data.Treestore dynamic loading



ChillsNL
18 Apr 2011, 12:30 AM
Hello people, good morning.

I've worked my ass of friday to create an Ext.Data.Treestore. It is a kind of familiar with the demo of kitchensink. I've got another problem with loading data from a webservice into this Store. As this examples shows, all the links are hardcoded. Now i need to adjust the Store and model so it loads the data in mylist.js and put the links in the list.


FWM.Structure =
[{
text: 'User Interface',
source: 'list.js',
cls: 'launchscreen',
card: Ext.is.Phone ? false : GW.List,
items:
[{
text: 'Dossiers',
card: GW.Dossier,
source: 'dossier.js',
leaf: true
},
{
text: 'List',
card: GW.List,
source: 'list.js',
leaf: true
}]
}];


Ext.regModel
('myMobile',
{
fields:
[
{name: 'text', type: 'string'},
{name: 'source', type: 'string'},
{name: 'card'}
]
}
);

FWM.StructureStore = new Ext.data.TreeStore
(
{
model: 'myMobile',
root:
{
items: FWM.Structure
},
proxy:
{
type: 'ajax',
reader:
{
type: 'tree',
root: 'items'
}
}
}
);


{
"MyLists": [
{
"text": "User Interface",
"source": "list.js",
"items": "[]",
"card": "Ext.is.Phone ? false : GW.List"
},
{
"text": "Dossier",
"source": "dossier.js",
"items": "[]",
"card": "Ext.is.Phone ? false : GW.Dossier"
}
]
}

So the question is, is there someone willing to help me? It's important cause it's for my school project and got 6 weeks left. Really need some help.
Thnx!

ChillsNL
18 Apr 2011, 5:16 AM
Well, i've worked my ass of this morning and got something else now. It finnaly loads, but now i want, when i click on on of the items in the nested list, that it goes to a new card.

Here is my code now.

Ext.regModel('myMobile',{
fields:
[
{name: 'text', type: 'string'},
{name: 'source', type: 'string'},
{name: 'items', type: 'string'},
{name: 'card'}
]
});

FWM.StructureStore = new Ext.data.TreeStore({
model: 'myMobile',
proxy: {
type: 'ajax',
url: 'mylist.json',
reader: {
type: 'tree',
root: 'items'
}
}
});


this.navigationPanel = new Ext.NestedList
({
store : FWM.StructureStore,
useToolbar : Ext.is.Phone ? false : true,
updateTitleText : false,
dock : 'left',
ui :'dark',
hidden : !Ext.is.Phone && Ext.Viewport.orientation == 'portrait',
toolbar : Ext.is.Phone ? this.navigationBar : null,
listeners :
{
itemtap : this.onNavPanelItemTap,
scope : this
}
});


{
"items": [
{
"text": "List",
"source": "list.js",
"items": "[]",
"card": "Ext.is.Phone ? false : GW.List"
},
{
"text": "Dossier",
"source": "dossier.js",
"items": "[]",
"card": "Ext.is.Phone ? false : GW.Dossier"
}
]
}

So how can I make a link work? I need the source and the card for that, anyone has an idea?

ChillsNL
18 Apr 2011, 11:30 PM
Anyone has an clue? I've made the dynamic loading in the nested work to work.

How can i go to the next page when clicking on an item in the list?

ChillsNL
19 Apr 2011, 4:06 AM
Well, after I made some adjustments to the code, i've succesfully loaded 6 items into the NestedList. The only problem is that the items need to function as links.

When I press on of the link items, it needs to redirect to another card. So the coded makes a new empty page. Anyone has an clue how to work with sources and card to make it work? Code is in the previous posts