Dear all,
I found on https://fiddle.sencha.com/#fiddle/243u&view/editor a nice example of a lazy loading of nodes in a tree.
Here's the code:
Code:
Ext.onReady(
function()
{
Ext.create(
{
xtype : 'treepanel',
viewModel: {
stores: {
pages: {
type : 'tree',
parentIdProperty: 'pId',
proxy : {
type: 'ajax',
url : '../JSONFiles/pages.json'
}
}
}
},
bind : '{pages}' ,
rootVisible: false ,
animate : false ,
renderTo : Ext.getBody()
});
});
What is confusing me is the syntax of the pages.json file, which is declared to be (in Fiddle) as:
Code:
function(params, req, Fiddle)
{
var pages = {
"root": [
{
"id" : 1 ,
"pId" : "root" ,
"text" : "One" ,
"expanded": true
}
],
1 : [
{
"id" : 2 ,
"pId" : 1 ,
"text" : "Two" ,
"expanded": true
}
],
2 : [
{
"id" : 3 ,
"pId" : 2 ,
"text" : "Three",
"leaf" : true
},
{
"id" : 4 ,
"pId" : 2 ,
"text" : "Four" ,
"expanded": true
}
],
4 : [
{
"id" : 5 ,
"pId" : 4 ,
"text" : "Five" ,
"leaf" : true
}
]
};
return pages[params.node];
}
Using this file as pages.json I get the following error: "SyntaxError: JSON.parse: unexpected keyword at line 1 column 1 of the JSON data"
What's confusing me is this is NOT supposed, in fact, to be a correct json file syntax.
What is the EXACT format of the pages.json file in order to make the example work correctly?
Thanks.