This is a migrated thread and some comments may be shown as answers.

Programmatic Nodes

6 Answers 172 Views
OrgChart
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 28 Feb 2013, 11:53 PM
I'm creating a dependency tree programmatically in code-behind. Overall, it works. Unfortunately, they all show up as group nodes. Could you please provide an examples of how to programmatically add a single item as opposed to a group node? Thanks.

Matthew Ricks

6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 05 Mar 2013, 04:03 PM
Hi Matthew,

 
A similar functionality is implemented in this on-line demo.

Hope this will be helpful.

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Matthew
Top achievements
Rank 1
answered on 05 Mar 2013, 09:26 PM
Forgive me. I don't want group nodes--at all. Something similar to this in appearance. I have to selectively add templates, so I have to make the nodes in the code behind, but it seems I can only make group nodes.
0
Matthew
Top achievements
Rank 1
answered on 08 Mar 2013, 12:01 AM
Simplified, this is what I'm doing. The initial call passes in the OrgChart as parent.
private void LoadServiceNode(IOrgChartNodeContainer parent, int serviceID)
    {
        if (services.Count(s => s.ServiceID == serviceID) == 0) return;
        Service service = services.First(s => s.ServiceID == serviceID);
        services.Remove(service);
 
        OrgChartNode snode = new OrgChartNode();
        snode.GroupItems.Add(new OrgChartGroupItem { CssClass = "Service", DataItem = service, Template = new ServiceTemplate() });
 
        // Load Required Services
        if (service.Dependencies.Count > 0)
        {
            OrgChartNode node = new OrgChartNode();
            node.GroupItems.Add(new OrgChartGroupItem { CssClass = "Service", DataItem = service, Template = new ServicesTemplate() });
            foreach (Service dependency in service.Dependencies.OrderBy(s => s.RequiredService.ServiceLaunchDate).Select(d => d.RequiredService))
            {
                LoadServiceNode(node, dependency.ServiceID);
            }
            if (node.Nodes.Count > 0) snode.Nodes.Add(node);
        }
 
        snode.Collapsed = true;
        parent.Nodes.Add(snode);
    }

Again, I don't want group nodes (the gray borders), I just want normal nodes. I've attached what I've currently got. Keep in mind this uses the extended function. What I've given should show what I'm doing, and, more importantly, what I'm doing wrong.
0
Plamen
Telerik team
answered on 08 Mar 2013, 12:18 PM
Hello Matthew,

 
If you are trying to remove the background grey color that surrounds the nodes you can achieve it with css as in the code below or with setting some other color:

<style type="text/css">
        .rocGroup {
    background-color: transparent !important;
}
    </style>

Hope this will be helpful.

Kind regards,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Matthew
Top achievements
Rank 1
answered on 08 Mar 2013, 03:22 PM
I'm not just trying to remove the color. You solution leaves a gap around the nodes, the lines don't go all the way, and if I try to compensate the arrows and/or lines get out of whack. I've attached a sample of what I've been able to do with CSS. Is there not a programmatic way to add a regular node instead of a group node?

And by the way, I don't know if others experience this issue, but the postbacks after submitting replies like this take an unreasonably long time for me. It'd be nice if that weren't the case.
0
Plamen
Telerik team
answered on 13 Mar 2013, 12:14 PM
Hello,

 
If you want to have regular nodes I will recommend you to use simple binding as for example it is done in this on-line demo or if you are using load on demand this on-line demo instead of using group enabled. 

As for the issue with the Postback after submitting replies -we will investigate the issue-thank you for reporting it.

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
OrgChart
Asked by
Matthew
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or