TreeNode.Children returned from TreeProvider.SelectSingleDocument() is empty. How can I get it to be

Drew Null asked on April 24, 2014 16:32

TreeProvider.SelectSingleDocument(DocumentID) returns a TreeNode in which the Children property is empty.

When I am logged in to Kentico as an administrator, however, it is populated with the TreeNode's child documents.

How do I get a TreeNode plus it's children for an anonymous user? Preferably only its immediate children but no other descendants. I would prefer not to new up my TreeProvider with an administrator.


Correct Answer

Drew Null answered on April 24, 2014 17:14

To answer my own question...

TreeNode document = treeProvider.SelectSingleDocument(documentId, true);
NodeSelectionParameters childrenSelectParams = new NodeSelectionParameters();
childrenSelectParams.AliasPath = string.Format("{0}/%", document.NodeAliasPath);
childrenSelectParams.MaxRelativeLevel = 1;
TreeNodeDataSet children = treeProvider.SelectNodes(childrenSelectParams);
0 votesVote for this answer Unmark Correct answer

Recent Answers

Andrew Balla answered on February 12, 2016 20:20

Thanks for this solution, but I would like to know why the TreeNode.Children property doesn't show child document for anonymous users. Any Kentico support engineers have an idea?


0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.