PDA

View Full Version : tree loading data



toxkillfraex
4 Apr 2012, 6:14 AM
I'm absolutely unclear how to work with a tree I've managed to create a dummy tree for styling but that's it.

I'm supposed to be loading the same data as another panel that orders it in accordion panels (represents the folders) with tabs (represents sub folders) data views (contains the documents)

for each of the three (folders, sub folders and documents) I've defined custom iconCls. but the server doesn't return these.

instead I get json that pretty much looks like this:



{"folder: {"id":1, "documents":[], "label": "somedate",
"subFolders":
[{"id":20,
"documents":
[{"id":50,
"title":"documentName",
"thumbnailUrl":"http..etc.",
//some more data here
}],
"label":"someName",
"subFolders":[]}
]}"}


the models used for the other panel look like this


Ext.define('App.model.Folder',
{
extend: 'Ext.data.Model',

fields:
[
{name: 'id', type: 'int'},
{name: 'label', type: 'string'}
],
associations:
[
{type: 'hasMany', model: 'App.model.DocumentThumbs', name: 'documents', associationKey:'documents'},
{type: 'hasMany', model: 'App.model.Folder', name: 'subFolders', associationKey:'subFolders'}
]
});

Ext.define('App.model.DocumentThumbs',
{
extend: 'Ext.data.Model',

fields:
[
{name: 'dynamic', type: 'boolean'},
{name: 'id', type: 'int'},
{name: 'title', type: 'string'},
{name: 'thumbnailUrl', type: 'string', defaultValue: 'resources/images/placeholder.png'},
{name: 'favorite', type: 'boolean'}
],

belongsTo: 'App.model.Folder'
});


the store used for the other panel looks like this


folderStore = Ext.create('Ext.data.Store',
{
model : 'App.model.Folder',
proxy :
{
type : 'rest',
url : App.model.Cookie.config.serverUrl + '/contact/'
+ contact.data.ID + '/documents',

reader :
{
type : 'json',
root : 'folder'
},

actionMethods :
{
read : 'GET'
},

extraParams :
{
sessionId : session.sessionId
},

autoLoad : true
}
});


the custom iconCls I have defined are TreeFile, TreeSubFolder and TreeFolder

I don't know how much I'll need to redefine. For all I know I'll need a whole new store and/or model.

any help or directions to tutorials other threads with the same issue are apreciated

toxkillfraex
4 Apr 2012, 11:40 PM
if the data really needs to be adapted I can always ask the server guys to add another method returning exactly what I'd need.
Though I'd rather see that as a final resort

toxkillfraex
6 Apr 2012, 12:22 AM
bump

toxkillfraex
8 Apr 2012, 9:53 PM
bump