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

Setting the parent in the middle of a tree

2 Answers 39 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 14 Apr 2011, 04:49 AM
Hi there.

I have a large organisational structure. When I load my page showing details of an item half way down the tree I want to load my RadTreeList using the selected item as the parent so that it only shows the current item as the parent and then all its children. Anything above it is ignored. So I'm specifying a dynamic starting parentID essentially

Thanks
Chris

2 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Apr 2011, 08:29 AM
RadTreeList does not support specifying the default values for the keys of root items. It looks for items whose data key values have a default value (e.g.  0 for int, null for nullable, etc.) If you need to specify a set of data items that do not have items that qualify as root in RadTreeList terms, you need to modify your data. For example, you can iterate over the data items, identify the roots, set their data key values to their defaults and add the modified items in a custom collection. Then you can pass RadTreeList this modified collection when databinding.

Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Chris
Top achievements
Rank 1
answered on 15 May 2011, 06:54 AM
I created an easy SQL only solution to setting the TreeList control to whatever point within my org tree.

Using a CASE statement in my select statement, if the ChildID equals where I want to start my tree I set the ParentOUID to 0. E.g.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SELECT TOP (100) PERCENT dbo._OFLENZ0001OURelationship.OUFacilityID, CASE WHEN dbo._OFLENZ0001OU.OUID = @OUID THEN 0 ELSE dbo._OFLENZ0001OURelationship.ParentOUID END as ParentOUID, dbo._OFLENZ0001OU.OUID, dbo._OFLENZ0001OU.TenantID, dbo._OFLENZ0001OU.OrganisationName, dbo._OFLENZ0001OU.OUCode, dbo._OFLENZ0001OU.Address, dbo._OFLENZ0001OU.City, dbo._OFLENZ0001OU.OUGUID FROM dbo._OFLENZ0001OU INNER JOIN dbo._OFLENZ0001OURelationship ON dbo._OFLENZ0001OU.OUID = dbo._OFLENZ0001OURelationship.ChildOUID WHERE (dbo._OFLENZ0001OURelationship.IsProgramRelatedRelationship = 0) AND (dbo._OFLENZ0001OU.TenantID = 2) ORDER BY dbo._OFLENZ0001OU.TenantID, dbo._OFLENZ0001OU.OUID">
    <SelectParameters>
        <asp:QueryStringParameter Name="OUID" QueryStringField="o" DbType="Int32" />
        <asp:SessionParameter Name="TenantID" SessionField="TenantID" DbType="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

Hope this helps someone.

Cheers
Chris
Tags
TreeList
Asked by
Chris
Top achievements
Rank 1
Answers by
Veli
Telerik team
Chris
Top achievements
Rank 1
Share this question
or