i am new to KendoUI so i was wondering if/how i can use data represented with the new HierarchyId datatype in my sql server database in my KendoUI TreeView. Are there any suggestions on how to approach this?
Asked
Active
Viewed 764 times
1 Answers
2
Assuming that you have chosen the default value for loadOnDemand
, I would suggest to map the id
of the node in one column (id
) and the text in another (text
) and the id
of the parent node in another (pid
).
So the following tree:
root -+- Node1
+- Node2 -+- Node2.1
| +- Node2.2
+- Node3
Would be stored as:
ID PID TEXT
------- ------- --------
root null Root
node1 root Node1
node2 root Node2
node3 root Node3
node2.1 node2 Node2.1
node2.2 node2 Node2.2
Each time that KendoUI wants to expand
a node, if will send a request with the id
of the node being expanded
Example:
http://myserver/getChildren?id=node2.2
Which selects the sub-nodes of the node Node2.2 (which id
is node2.2). And the SQL statement would be:
SELECT ID, TEXT FROM KENDO_TREE WHERE (PID = 'node2.2');

OnaBai
- 40,767
- 6
- 96
- 125