Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, I am following the source code written by Dave Woestenborghs on creating custom sections. The source code can be found here: https://bitbucket.org/dawoe/duugcustomsections/src
When I add few customers, they appear below each other with no grouping root node. How to be able to do so?
Here is some code snippets:
[Tree("duug-customers", "duug-customers-tree", "Customers")] [PluginController("DUUG")] public class CustomerTreeController : TreeController { private const string CustomerPrefix = "customer-"; protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) { // if not root, return all nodes if (id != Constants.System.Root.ToInvariantString()) throw new NotSupportedException(); var nodes = new TreeNodeCollection(); var ctrl = new CustomersController(); var customerRoute = string.Format("{0}{1}/edit/", queryStrings.GetValue<string>("application"), this.TreeAlias.EnsureStartsWith('/')); nodes.AddRange(ctrl.GetAll().Select(customer => CreateTreeNode(string.Format("{0}{1}", CustomerPrefix, customer.Id.ToString(CultureInfo.InvariantCulture)), Constants.System.Root.ToInvariantString(), queryStrings, customer.Name, "icon-client", false, string.Format("{0}{1}", customerRoute, customer.Id)))); return nodes; } }
Any idea?
Thanks
Hi Bilal,
This because you have only one tree in your section and you add all your items to that.
Have a look at the source code here : https://bitbucket.org/dawoe/umbukfestival2014
In this example I have 2 trees and you see the behavior you want.
Dave
In fact, I added the following to get a root node:
if (id == Constants.System.Root.ToInvariantString()) { nodes.Add(CreateTreeNode("customersTree", Constants.System.Root.ToInvariantString(), queryStrings, "Customers", "icon-folder", true)); } else if (id == "customersTree") { var ctrl = new CustomersController(); var customerRoute = string.Format("{0}{1}/edit/", queryStrings.GetValue<string>("application"), this.TreeAlias.EnsureStartsWith('/')); nodes.AddRange( ctrl.GetAll() .Select( customer => CreateTreeNode( string.Format("{0}{1}", CustomerPrefix, customer.Id.ToString(CultureInfo.InvariantCulture)), Constants.System.Root.ToInvariantString(), queryStrings, customer.Name, "icon-client", false, string.Format("{0}{1}", customerRoute, customer.Id)))); }
But now the thing is, where in Umbraco I would specify a view to be shown when the section is clicked? Like a landing page or so.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Root node not showing in a custom section
Hi, I am following the source code written by Dave Woestenborghs on creating custom sections. The source code can be found here: https://bitbucket.org/dawoe/duugcustomsections/src
When I add few customers, they appear below each other with no grouping root node. How to be able to do so?
Here is some code snippets:
Any idea?
Thanks
Hi Bilal,
This because you have only one tree in your section and you add all your items to that.
Have a look at the source code here : https://bitbucket.org/dawoe/umbukfestival2014
In this example I have 2 trees and you see the behavior you want.
Dave
In fact, I added the following to get a root node:
But now the thing is, where in Umbraco I would specify a view to be shown when the section is clicked? Like a landing page or so.
Thanks
is working on a reply...