I've build a custom tree (as explained here: http://www.netaddicts.be/articles/building-a-custom-section-to-manage-external-data.aspx ) and it works fine in Umbraco 4.0.X . I've upgraded my test installation to 4.1.Beta II and now the tree will only show its top nodes. I've debugged the session, where the 4.0 looped trough the render method several times , the 4.1 does it only once.
I cant find any documentation about the new jstree or any incomatability issues. Any suggestions and\or help is greatly appreciated.
Code: (sorry, the editor made a mess of it)
using System; using System.Collections.Generic; using System.Web; using System.Text; using umbraco.cms.presentation.Trees; using umbraco.DataLayer; using umbraco.BusinessLogic; using umbraco.interfaces;
namespace Organisatiestructuur {
publicclassLoadOrganisatiestructuur : BaseTree {
public LoadOrganisatiestructuur(string application) : base(application)
Custom Tree in 4.1 does not show child nodes.
Hi,
I've build a custom tree (as explained here: http://www.netaddicts.be/articles/building-a-custom-section-to-manage-external-data.aspx ) and it works fine in Umbraco 4.0.X . I've upgraded my test installation to 4.1.Beta II and now the tree will only show its top nodes. I've debugged the session, where the 4.0 looped trough the render method several times , the 4.1 does it only once.
I cant find any documentation about the new jstree or any incomatability issues. Any suggestions and\or help is greatly appreciated.
Code: (sorry, the editor made a mess of it)
using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using umbraco.cms.presentation.Trees;
using umbraco.DataLayer;
using umbraco.BusinessLogic;
using umbraco.interfaces;
namespace Organisatiestructuur {
public class LoadOrganisatiestructuur : BaseTree {
public LoadOrganisatiestructuur(string application) : base(application)
{ }
protected override void CreateRootNode(ref XmlTreeNode rootNode)
{
rootNode.Text =
"Organisatiestructuur";
rootNode.Icon = FolderIcon;
rootNode.OpenIcon = FolderIconOpen;
rootNode.NodeType = string.Format("init{0}", TreeAlias);
rootNode.NodeID = "-1";
}
{
Javascript.Append(
@"function openCollege(id) {parent.right.document.location.href = 'plugins/editOrganisatiestructuur.aspx?id=' + id;}");
public override void Render(ref XmlTree tree)
{
if (this.NodeKey == string.Empty)
{
//root nodes
// var reader = Application.SqlHelper.ExecuteReader(@"select * from rocwb_umbraco_shared.dbo.[college]");
var reader = Application.SqlHelper.ExecuteReader(@"select * from [college]");
while
(reader.Read())
{
XmlTreeNode node = XmlTreeNode.Create(this
);
node.NodeID =
Convert.ToString(reader.Get<int>("col_id"));
node.Text = reader.Get<
string>("col_naam");
node.OpenIcon = FolderIconOpen;
node.Icon = FolderIcon;
//node.Icon = "letter.gif";
node.Action =
string.Format("javascript:openCollege('{0}');", node.NodeID);
TreeService treeService = new TreeService(-1, TreeAlias, ShowContextMenu, IsDialog, DialogMode, app, string.Format("College-{0}", Convert.ToString(reader.Get<int>("col_id"))));
node.Source = treeService.GetServiceUrl();
tree.Add(node);
}
}
else
{
switch (this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[0])
{
case "College"
:
/* rocwb_umbraco_shared.dbo. */
var afdelingReader = Application.SqlHelper.ExecuteReader(
@"SELECT * from [afdeling]WHERE afd_col_id = @College ",
Application.SqlHelper.CreateParameter("@College", this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]));
while
(afdelingReader.Read())
{
XmlTreeNode node = XmlTreeNode.Create(this
);
node.NodeID =
"afd" + Convert.ToString(afdelingReader.Get<int>("afd_id"));
node.Text = afdelingReader.Get<
string>("afd_naam");
node.OpenIcon = FolderIconOpen;
node.Icon = FolderIcon;
node.Action =
string.Format("javascript:openAfdeling('{0}');", node.NodeID);
TreeService treeService = new TreeService(-1, TreeAlias, ShowContextMenu, IsDialog, DialogMode, app, string.Format("Afdeling-{0}", "afd" + Convert.ToString(afdelingReader.Get<int>("afd_id"))));
node.Source = treeService.GetServiceUrl();
tree.Add(node);
}
break;
case "Afdeling":
// standaard node voor opleidingen
XmlTreeNode nodeOpl = XmlTreeNode.Create(this
);
nodeOpl.NodeID =
"Opleidingen" + this.NodeKey.Split(new string[] { "-" }, StringSplitOptions
.RemoveEmptyEntries)[1];
nodeOpl.Text =
"Opleidingen";
nodeOpl.OpenIcon = FolderIconOpen;
nodeOpl.Icon = FolderIcon;
nodeOpl.Action =
string.Empty;
TreeService treeServiceOpl = new TreeService(-1, TreeAlias, ShowContextMenu, IsDialog, DialogMode, app, string.Format("AfdelingOpl-{0}", "afd" + this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]));
nodeOpl.Source = treeServiceOpl.GetServiceUrl();
tree.Add(nodeOpl);
// standaard node voor locaties
XmlTreeNode nodeLoc = XmlTreeNode.Create(this
);
nodeLoc.NodeID =
"Locaties" + this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1];
nodeLoc.Text =
"Locaties";
nodeLoc.OpenIcon = FolderIconOpen;
nodeLoc.Icon = FolderIcon;
nodeLoc.Action =
string.Empty;
TreeService treeServiceLoc = new TreeService(-1, TreeAlias, ShowContextMenu, IsDialog, DialogMode, app, string.Format("AfdelingLoc-{0}", "afd" + this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]));
nodeLoc.Source = treeServiceLoc.GetServiceUrl();
tree.Add(nodeLoc);
break;
case "AfdelingOpl":
var opleidingReader = Application.SqlHelper.ExecuteReader(@"SELECT * FROM [opleiding] WHERE opl_afd_id = replace(@Afdeling,'afd','')",
Application.SqlHelper.CreateParameter("@Afdeling", this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]));
while
(opleidingReader.Read())
{
XmlTreeNode node = XmlTreeNode.Create(this
);
node.NodeID =
"opl" + Convert.ToString(opleidingReader.Get<int>("opl_id"));
node.Text = opleidingReader.Get<
string>("opl_naam");
node.OpenIcon = FolderIconOpen;
node.Icon = FolderIcon;
node.Action =
string.Empty;
node.Source =
string.Empty;
tree.Add(node);
}
break;
case "AfdelingLoc":
var locatieReader = Application.SqlHelper.ExecuteReader(@"SELECT * from [locatie] WHERE loc_afd_id = replace(@Afdeling,'afd','')",
Application.SqlHelper.CreateParameter("@Afdeling", this.NodeKey.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]));
while
(locatieReader.Read())
{
XmlTreeNode node = XmlTreeNode.Create(this);
node.NodeID =
"loc" + Convert.ToString(locatieReader.Get<int>("loc_id"));
node.Text =
Convert.ToString(locatieReader.Get<string>("loc_naam"));
node.OpenIcon = FolderIconOpen;
node.Icon = FolderIcon;
node.Action =
string.Empty;
node.Source =
string.Empty;
tree.Add(node);
}
break;
default:
break;
}
}
}
}
}
I'm in the same boat, Bob. I've noticed some mentions about changes to the tree in 4.1, but no documentation about how to work with those changes....
You need to set the HasChildren property of the XmlTreeNode object:
node.HasChildren = true; //for when the node actually has children.
This property is actually supposed to be set even in v4.0.x
In 4.1, due to the changes in the tree, this property needs to be set, otherwise it defaults to false.
Hope this helps,
Shannon
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.