Copied to clipboard

Flag this post as spam?

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


  • Kevon K. Hayes 255 posts 281 karma points
    Jan 14, 2010 @ 05:24
    Kevon K. Hayes
    0

    Loop issue when creating custom nodes

    I was wondering if someone can point out where I'm going wrong with my loop.  I have a menu system I'm attempting to build.  Whenever I create a node all the other nodes I've created previously gets populated under that node.   It doesn't matter if the node I create is a parent or a child.  Whenever I go to create a new node and begin to expand the tree all the nodes I've previously created childs or siblings are now childs of my new node.  Here's an example:

    Watch the progression as I expand:

    1. http://i8dm.com/images/createnodeimage002.png

    2. http://i8dm.com/images/createnodeimage003.png

    3. http://i8dm.com/images/createnodeimage004.png

    Here's my code:

    namespace i8Menus
    {
        public class loadi8MenuTree : BaseTree
        {
            public loadi8MenuTree(string application)
                : base(application)
            {

            }

            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                rootNode.Icon = FolderIcon;
                rootNode.OpenIcon = FolderIconOpen;
                rootNode.HasChildren = true;
                rootNode.NodeType = TreeAlias;
                rootNode.NodeID = "init";
            }

            protected override void CreateAllowedActions(ref List<IAction> actions)
            {
                actions.Clear();
                actions.Add(ActionNew.Instance);
                actions.Add(ActionDelete.Instance);
                actions.Add(ActionMove.Instance);
                actions.Add(ActionSort.Instance);
                actions.Add(ContextMenuSeperator.Instance);

                actions.Add(ActionRefresh.Instance);
                //base.CreateAllowedActions(ref actions);
            }

            public override void RenderJS(ref System.Text.StringBuilder Javascript)
            {
                Javascript.Append(
                @"
                        function openi8MenuTree(menuID)
                        {
                            parent.right.document.location.href = 'plugins/editi8MenuTree.aspx?menuID=' + menuID;
                        }
                ");

            }


            public override void Render(ref XmlTree tree)
            {
                IRecordsReader reader = Application.SqlHelper.ExecuteReader("SELECT * FROM i8Menus");

                while (reader.Read())
                {
                    // Probably missing a statement here...


                        XmlTreeNode xNode = XmlTreeNode.Create(this);

                        xNode.NodeID = reader.GetInt("menuID").ToString();
                        xNode.HasChildren = true;
                        xNode.Source = xNode.HasChildren ? this.GetTreeServiceUrl(xNode.NodeID) : "";
                        xNode.Text = reader.GetString("menuName");
                        xNode.Icon = "i8TreeIcon.gif";
                        xNode.Action = "javascript:openi8MenuTree(" + reader.GetInt("menuID").ToString() + ")";
                        xNode.Source = this.GetTreeServiceUrl(xNode.NodeID);
                       
                        tree.Add(xNode);


                }

            }
        }
    }

  • Richard Soeteman 4052 posts 12925 karma points MVP 2x
    Jan 14, 2010 @ 06:11
    Richard Soeteman
    2

    HI,

    I think you should take a look at this great tutorial from Dirk

    Hope it helps you,

    Richard 

  • Kevon K. Hayes 255 posts 281 karma points
    Jan 15, 2010 @ 05:28
    Kevon K. Hayes
    0

    Tis a nice tutorial... I think I may be getting somewhere.  But not just yet.

Please Sign in or register to post replies

Write your reply to:

Draft