Item has children in Hierarchical View

Tommy De Notarpietro asked on October 26, 2016 14:36

In a hierarchical view, I can use "NodeHasChildren" to check if an item has children. An alternative is using "Documents.Where("NodeID = " + NodeID).FirstItem.Children.Count > 0". Now I realized the "NodeHasChildren" can't be used when you want to check on "show on navigation" or your datasource is filtered by categories.

How can I check if there are children in these situation? ( Without using javascript for manipulating the dom )

Recent Answers


Brenden Kehren answered on October 26, 2016 14:59

You can use both in your where clause:

DocumentMenuItemHideInNavigation = 0 AND NodeHasChildren = 1

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on October 26, 2016 15:26

Try:

Documents.Where("DocumentMenuItemHideInNavigation = 0 AND NodeParentID = " + NodeID).Count > 0

1 votesVote for this answer Mark as a Correct answer

Tommy De Notarpietro answered on October 27, 2016 15:11

This works for the "show on navigation" check. Is there also a solution when your hierarchical view shows only a certain category? So you have something like Documents.Where("NodeParentID = " + NodeID + " AND DocumentCategory = 'MyCategory'").Count. I suppose there's no field to use in the where field.

0 votesVote for this answer Mark as a Correct answer

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