I have a small issue that I'm trying to work through. When I go to
create a child node under a child node, it gets created as a child of
the parent and not a child of a child?
e.g. ...
-root node --node (I try to create a new node here) --node (it goes here for some reason) ---node(and not here)
Here's my code:
namespace i8Menus { public class loadi8MenuTree : BaseTree { public loadi8MenuTree(string application):base(application) {
Node getting created under incorrect node
I have a small issue that I'm trying to work through. When I go to create a child node under a child node, it gets created as a child of the parent and not a child of a child?
e.g. ...
-root node
--node (I try to create a new node here)
--node (it goes here for some reason)
---node(and not here)
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;
}
");
Javascript.Append(
@"
function openi8SubMenuTree(menuID)
{
parent.right.document.location.href = 'plugins/editi8SubMenuTree.aspx?menuID=' + menuID;
}
");
}
public override void Render(ref XmlTree tree)
{
IRecordsReader reader = Application.SqlHelper.ExecuteReader("SELECT * FROM i8Menus");
while (reader.Read())
{
// I'm probably missing a statement here...
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = reader.GetInt("menuID").ToString();
xNode.HasChildren = true;
xNode.Text = reader.GetString("menuName");
xNode.Icon = "i8TreeIcon.gif";
xNode.Action = "javascript:openi8MenuTree(" + reader.GetInt("menuID").ToString() + ")";
tree.Add(xNode);
}
}
}
}
I'm able to add a child node under a child node now, I added the following line to the code below:
public override void Render(ref XmlTree tree)
{
IRecordsReader reader = Application.SqlHelper.ExecuteReader("SELECT * FROM i8Menus");
while (reader.Read())
{
// I'm probably missing a statement here...
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = reader.GetInt("menuID").ToString();
xNode.HasChildren = true;
xNode.Text = reader.GetString("menuName");
xNode.Icon = "i8TreeIcon.gif";
xNode.Action = "javascript:openi8MenuTree(" + reader.GetInt("menuID").ToString() + ")";
xNode.Source = xNode.HasChildren ? this.GetTreeServiceUrl(xNode.NodeID) : "";
tree.Add(xNode);
}
}
...the problem is my loop is repeating nodes at the child level see example here: http://www.i8dm.com/images/createnodeimage002.png and http://www.i8dm.com/images/createnodeimage003.png I haven't seen a good example on doing this without using a Dictionary datatype. Just looking for suggestions on how to correctly do this without repeating nodes.
is working on a reply...