PDA

View Full Version : Tree Store



tina@user
25 Aug 2015, 3:05 AM
hi,
i have a tree store


Ext.define('App.store.ImageTemplateTreeGridStore', {
extend : 'Ext.data.TreeStore',
storeId : 'ImageTemplateTreeGridStore',
//model : 'App.model.ImageTemplateTreeGridModel',
autoLoad : true,
proxy : {
type : 'ajax',

url: 'rest/NewCloudRequest/getCloudXImages/Vashi-iLabs/13',
reader : {
type : 'json',
root : 'response'
}
},
autoSync:true,
root : {
data:'Root',
expanded:true
},


and mu json repsonse is :-


root : {
"text" : null,
"id" : 0,
"children" : [ {
"text" : "Windows",
"id" : 1,
"children" : [ {
"text" : "Windows 2012 Standard 64 Bit",
"id" : 182,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2003 32 Bit Enterprise",
"id" : 103,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2003 64 Bit Enterprise",
"id" : 105,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2003 32 Bit Standard",
"id" : 49,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2003 64 Bit Standard",
"id" : 106,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2008 32 Bit Enterprise",
"id" : 52,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2008 R2 64 Bit Enterprise",
"id" : 217,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2008 R2 64 Bit Enterprise",
"id" : 54,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2008 32 Bit Standard",
"id" : 53,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 2008 R2 64 Bit Standard",
"id" : 55,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 7 Professional 32 Bit ",
"id" : 157,
"children" : null,
"leaf" : true
}, {
"text" : "Windows 7 Professional 64 Bit",
"id" : 118,
"children" : null,
"leaf" : true
}, {
"text" : "Windows XP 32 bit Professional ",
"id" : 56,
"children" : null,
"leaf" : true
} ],
"leaf" : false
}, {
"text" : "RHEL",
"id" : 4,
"children" : [ {
"text" : "Red Hat 5.5 Server 64 Bit",
"id" : 131,
"children" : null,
"leaf" : true
} ],
"leaf" : false
}, {
"text" : "Ubuntu",
"id" : 3,
"children" : [ {
"text" : "Ubuntu Desktop 10.04",
"id" : 48,
"children" : null,
"leaf" : true
}, {
"text" : "Ubuntu 11.10 Desktop",
"id" : 126,
"children" : null,
"leaf" : true
}, {
"text" : "Ubuntu 12.04",
"id" : 173,
"children" : null,
"leaf" : true
} ],
"leaf" : false
}, {
"text" : "Centos",
"id" : 2,
"children" : [ {
"text" : "CentOS 5.4",
"id" : 97,
"children" : null,
"leaf" : true
}, {
"text" : "CentOS 5.4",
"id" : 128,
"children" : null,
"leaf" : true
} ],
"leaf" : false
} ],
"leaf" : false
}


and my view is:-


Ext.define('App.view.ImageTemplateTreeGrid', {
extend: 'Ext.tree.Panel',
store: 'ImageTemplateTreeGridStore',
// id:'ImageTemplateTreeGrid',
alias: 'widget.ImageTemplateTreeGrid',
cls:'imageTemplate-grid',

useArrows: true,
// overflowY:'auto',
height:234,
frame: true,
autoScroll: true,
});


the root is visible but the chidren is never visible
When i expand it i get the error
Uncaught TypeError: Cannot read property 'internalId' of undefined

Please help!

chamacs
25 Aug 2015, 4:24 AM
should 'root' on this line be all lowercase to match the json response?


data:'Root'

tina@user
25 Aug 2015, 7:01 AM
I tried to do dat too but the problem still persists...

I have tried giving data:'root'
And also empty data:''

But nothing seems to work!!

Plese rescue...its urgent and i cant seem to track the error

joel.watson
29 Aug 2015, 11:37 AM
Hi--

Does this work for you?

https://fiddle.sencha.com/#fiddle/t1v

Thanks!
Joel

tina@user
30 Aug 2015, 10:26 PM
Hi--

Does this work for you?

https://fiddle.sencha.com/#fiddle/t1v

Thanks!
Joel

yes, It perfectly works.
The why doesnt it work in my workspace?
Is there any problem with my server data??

Thanks,
tina@usr

joel.watson
31 Aug 2015, 5:09 AM
Hi--

I believe the issue is that you were returning the full root data in the remote request, even though you had already set a root on your tree store. Because the root already exists, the remote request expects that you are returning the child nodes for the requested node (which in this case is the root).

Thanks!
Joel

tina@user
31 Aug 2015, 5:28 AM
I am trying to do the same now.
Here is my store:'


Ext.define('App.store.ImageTemplateTreeGridStore', {
extend : 'Ext.data.TreeStore',
storeId : 'ImageTemplateTreeGridStore',
autoLoad : true,
proxy : {
type : 'ajax',
url: rest/NewRequest/getImages',
reader : {
type : 'json',
}
},
autoSync: true,
root : {
data:'Root',
expanded:true
},
});

but nothings happens

Only the Root is visible but its children are not visible.
My server data remains the same.

Thanx,
tina@user

joel.watson
31 Aug 2015, 5:37 AM
Hi--

Did you update your server data to match the example that I shared in the Fiddle (data1.json)?

Thanks
Joel

tina@user
31 Aug 2015, 5:39 AM
how can i get your format of server data?

Sorry for the silly question

joel.watson
31 Aug 2015, 5:44 AM
how can i get your format of server data?

Sorry for the silly question

When you make the remote request, a querystring param named "node" will be passed which is the id of the node you're currently requesting data for. You should be able to use this to query your server's data source and return an array of nodes (and their children) that represent the "children" of the requested node.

Thanks!
Joel

tina@user
2 Sep 2015, 4:34 AM
Thanx a lot joel.watson,

It worked really well!

Thanx again!

:)

joel.watson
2 Sep 2015, 5:16 AM
Sure thing, happy to help!

Thanks
Joel