Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Cort Larsen 421 posts 1038 karma points
    Jan 06, 2014 @ 12:20
    Peter Cort Larsen
    0

    Custom property editor, liste nodes

    Hi,

    I need to create a custom property editor, that lists certain document types in a checkboxlist, so a user can select these pages.

    I started here:

    http://umbraco.github.io/Belle/#/tutorials/CreatingAPropertyEditor

    But how do i list the nodes, that i want to appear in the checkboxlist, i have no idea how to accomplish this.

    Any ideas?

     

  • Peter Cort Larsen 421 posts 1038 karma points
    Jan 06, 2014 @ 13:14
    Peter Cort Larsen
    0

    I propably need to create a

    ApiController according to this tutorial:

    http://umbraco.github.io/Belle/#/tutorials/Add-ServerSide-Data

    I have this so far. But cant see how to combine it with the loop in my html, see code below. person in people, what will that be?

    namespace Ontranet.Categories
    {
        [Umbraco.Web.Mvc.PluginController("Ontranet")]
        public class CategoriesApiController : UmbracoAuthorizedJsonController
        {
            public static IEnumerable<Node> GetAllNodesByType(int NodeId, string typeName)
            {
                List<Node> foundNodes = new List<Node>();
                var node = new Node(NodeId);
                foreach (Node childNode in node.Children)
                {
                    var child = childNode;
                    if (child.NodeTypeAlias == typeName)
                    {
                        foundNodes.Add(child);
                    }
                    if (child.Children.Count > 0)
                        GetAllNodesByType(ref foundNodes, child, typeName);
                }
                return foundNodes.ToList();
            }
            private static void GetAllNodesByType(ref List<Node> foundNodes, Node node, string typeName)
            {
                foreach (Node childNode in node.Children)
                {
                    var child = childNode;
                    if (child.NodeTypeAlias == typeName)
                    {
                        foundNodes.Add(child);
                    }
                    if (child.Children.Count > 0)
                        GetAllNodesByType(ref foundNodes, child, typeName);
                }
            }
        }
    }

     

    Html :

    <ul> <li ng-repeat="person in people">
    <input type="checkbox"
    value="model.value = person.Name">{{person.Name}}</input>
    </li> </ul>
Please Sign in or register to post replies

Write your reply to:

Draft