Determining the Child Document Types

Shannon Dunn asked on August 27, 2014 17:26

I am working with a repeater and want to put a specific class attribute in the Container Before property for the "UL" tag depending on the number of child documents of a specific type. How can I in a K# macro for the Container Before property of the repeater, get the count of child documents of a specific type?

Recent Answers


Charles Matvchuk answered on August 27, 2014 19:52

<%# Eval("NodeChildNodesCount") %> Would give you the count of the child nodes.

Or write a custom function where you would feed the "NodeChildNodesCount" and the Document type (probably Class ?"). This would be the easiest.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 27, 2014 20:37

You might look into using a hierarchical viewer as well. This can handle those hierarchy items much more gracefully than a standard repeater.

0 votesVote for this answer Mark as a Correct answer

Shannon Dunn answered on August 27, 2014 23:28 (last edited on December 10, 2019 02:30)

Turns out it was easier to write it as part of the transformation and use a Text/XML transform instead of an ASCX and use K#:

{% if (DataItemCount == 1 && DataItemIndex == 0 ) { return "

    " } |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Shannon Dunn answered on August 27, 2014 23:30 (last edited on December 10, 2019 02:30)

Sorry code did not wrap propertly

{% if (DataItemCount == 1 && DataItemIndex == 0 ) { return "<ul class=\"single\">" } |(identity)GlobalAdministrator%}</span></a></li>
0 votesVote for this answer Mark as a Correct answer

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