Hello!
I have following data strucure: there are proejcts which has some items, these items can have other items as childs and as parents
accordingly.
--project1:
--item1
--item3
--item4
--item2
--project2:
//...
Entities is a simple array of Resource objects (I use REST functionality from AngularJS), and some of them has circular references to each other,
say I have some EntityDto which has Children property which is array of child entities, and there is also Parent property which points to parent entity.
EntityDto has following properties:
$id: "1"
Children: Array[2]
DtoKey: "EntityId=77"
EntityId: 77
Name: "file10.2"
Parent: null
So I decided to use existing functionality like hierarchical data source:
And of course it doesn't work... I guess I have to specify schema and model, but I didn't find any example that is similiar to my case.
I need to get somethin like this:
Can anybody explain, what I'm doing wrong? Or point to useful example or source code.
Thanks in advance.
UPDATE.
I will a little bit reformulate the question: is there a way in kendo-ui to get hierarchialEntities (see above) from array of EntitiesDto (see above)?
I supposed that HierarchicalDataSource can do that automatically, provide array of EntitiesDto and retrive hierarchialEntities...
I have following data strucure: there are proejcts which has some items, these items can have other items as childs and as parents
accordingly.
--project1:
--item1
--item3
--item4
--item2
--project2:
//...
EntityResource.query(
function
(entities)
{
//Entities are loaded dynamically when project selected.
//form data and append to tree
treeview.append(..., projectNode);
}
say I have some EntityDto which has Children property which is array of child entities, and there is also Parent property which points to parent entity.
EntityDto has following properties:
$id: "1"
Children: Array[2]
DtoKey: "EntityId=77"
EntityId: 77
Name: "file10.2"
Parent: null
So I decided to use existing functionality like hierarchical data source:
EntityResource.query(
function
(entities)
{
var
localDataSource =
new
kendo.data.HierarchicalDataSource({ data: entities});
localDataSource .fetch();
treeview.append(localDataSource ,projectNode);
}
I need to get somethin like this:
var
hierarchialEntities = [ {
EntityName:
"Parent1"
,
items: [
{ EntityName:
"Entity1"
, class:
'.entity-node'
, isEntity:
true
},
{ EntityName:
"Entity2"
, class:
'.entity-node'
, isEntity:
true
},
{ EntityName:
"Entity3"
, class:
'.entity-node'
, isEntity:
true
,
items: [{ EntityName:
"Entity7"
, class:
'.entity-node'
, isEntity:
true
}]
}
]
}, {
EntityName:
"Parent2"
,
items: [
{ EntityName:
"Entity4"
, class:
'.entity-node'
, isEntity:
true
},
{ EntityName:
"Entity5"
, class:
'.entity-node'
, isEntity:
true
},
{ EntityName:
"Entity6"
, class:
'.entity-node'
, isEntity:
true
}
]
}
];
treeview.append(hierarchialEntities,projectNode); //works as expected!!!
Can anybody explain, what I'm doing wrong? Or point to useful example or source code.
Thanks in advance.
UPDATE.
I will a little bit reformulate the question: is there a way in kendo-ui to get hierarchialEntities (see above) from array of EntitiesDto (see above)?
I supposed that HierarchicalDataSource can do that automatically, provide array of EntitiesDto and retrive hierarchialEntities...