I am having trouble to configure a TreePanel to show this JSON results from a REST API.
The JSON format is like this:
[
{
"guid": "{00000000-0000-0000-0000-000000000001}",
"name": "hhhh",
"vendor": "1",
"model": "1",
"address": "hhhh",
"port": 8080,
"redirect": false,
"optimizeBandwidth": true,
"reverseConnection": false,
"timeOutEnabled": false,
"timeOutInterval": 60,
"enabledCameras": 1,
"contactIdCode": "0001j",
"contactIdPartition": "00j",
"user": "jgjh",
"password": "ghghgh",
"enabled": true,
"connected": false
}
]
The name of the root node must be Servers
, and it's children node should be this JSON list, with the name of the node as the name
property. The other properties can be ignored, and these children will have no children in any situation.
I can only show in the TreePanel a root node without name, and it's children also without name, the number matching the number of objects in the JSON. they all have children also matching the number of objects in the JSON, without names, which also have children in the same way, to infinity.
I can't find which properties I should set to make the TreePanel work as I expect. I can't change the JSON as it is defined like this by the REST API.
Here's the TreePanel code:
....
{
xtype: 'treepanel',
title: 'Selecione o servidor',
flex: 1,
margin: 5,
store: Ext.create('Project.store.TreeServidor'),
},
....
Here's the code for the TreeStore:
Ext.define('Project.store.TreeServidor', {
extend: 'Ext.data.TreeStore',
model: 'Project.model.Servidor',
requires: 'project.model.Servidor',
root: {
expanded: true,
text: 'Servidores',
draggable: false,
id: 'guid',
root: 'name'
},
});
And finally the Model:
Ext.define('Project.model.Servidor', {
extend: 'Ext.data.Model',
fields: [
... too much big
],
proxy: {
type: 'rest',
url: 'http://localhost:8000/servers/',
noCache: false,
writer: {
type: 'json',
writeAllFields: true,
root: 'servers',
encode: true,
allowSingle: true
},
reader: {
type: 'json',
root: 'servers'
}
}
});