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

Self Referencing Hierarchy in Programmatic Grid with a xmlDataSource

3 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pylacroix
Top achievements
Rank 1
pylacroix asked on 26 Oct 2009, 01:48 PM
Hi,

I try to achieve a Self Referencing Hierarchy in Programmatic Grid with a xmlDataSource as defined on http://www.telerik.com/community/forums/aspnet-ajax/grid/self-referencing-hierarchy-in-programmatic-grid.aspx. I'm using RadControls for ASP.NET AJAX Q2 2009 (2009.2.826.35).

Here is a sample xml that I use

<Lines> 
    <Item ID="IDI-1-17" ParentID="" UserCode="B24R" Description="Base"/> 
    <Item ID="IDI-1-75" ParentID="IDI-1-17" UserCode="FL.TOE" Description="Flush Toe Kick"/> 
    <Item ID="IDI-1-20" ParentID="" UserCode="B24L" Description="Base"/> 
    <Item ID="IDI-1-57" ParentID="IDI-1-20" UserCode="FL.TOE" Description="Flush Toe Kick"/> 
    <Item ID="IDI-1-63" ParentID="IDI-1-20" UserCode="FD.SH" Description="Full Depth Shelf"/> 
    <Item ID="IDI-1-53" ParentID="IDI-1-20" UserCode="CT2" Description="Knife Section Kit"/> 
    <Item ID="IDI-1-26" ParentID="" UserCode="B36-2" Description="Base"/> 
    <Item ID="IDI-1-81" ParentID="IDI-1-26" UserCode="FL.TOE" Description="Flush Toe Kick"/> 
    <Item ID="IDI-1-36" ParentID="" UserCode="SBFD36" Description="Sink Base FHD"/> 
    <Item ID="IDI-1-83" ParentID="IDI-1-36" UserCode="FL.TOE" Description="Flush Toe Kick"/> 
    <Item ID="IDI-1-40" ParentID="IDI-1-36" UserCode="SK.21-1TUB" Description="21&quot; 1 Tub Sink"/> 
    <Item ID="IDI-1-22" ParentID="" UserCode="W2424" Description="Wall"/> 
    <Item ID="IDI-1-24" ParentID="" UserCode="W2424L-GL" Description="Wall w/Glass"/> 
</Lines> 
 

Here is the code which is very similar that the one in the other post

using System; 
using System.Data; 
using System.Configuration; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 
using Telerik.Web.UI; 
using System.Reflection; 
 
public partial class _Default : System.Web.UI.Page 
    public RadGrid RadGrid1 = new RadGrid(); 
 
    protected void Page_Init(object sender, System.EventArgs e) 
    { 
        XmlDataSource source = new XmlDataSource(); 
 
        source.EnableCaching = false
        source.DataFile = "~/AllLines.xml"
        source.XPath = "/Lines/Item"
 
        RadGrid1.ID = "RadGrid1"
        RadGrid1.DataSource = source; 
        RadGrid1.Width = Unit.Percentage(98); 
        RadGrid1.PageSize = 5; 
        RadGrid1.AllowPaging = true
        RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; 
        RadGrid1.AutoGenerateColumns = false
        GridBoundColumn boundColumn = new GridBoundColumn(); 
        boundColumn.DataField = "ID"
        boundColumn.HeaderText = "ID"
        RadGrid1.MasterTableView.Columns.Add(boundColumn); 
        boundColumn = new GridBoundColumn(); 
        boundColumn.DataField = "UserCode"
        boundColumn.HeaderText = "UserCode"
        RadGrid1.MasterTableView.Columns.Add(boundColumn); 
        boundColumn = new GridBoundColumn(); 
        boundColumn.DataField = "Description"
        boundColumn.HeaderText = "Description"
        RadGrid1.MasterTableView.Columns.Add(boundColumn); 
        boundColumn = new GridBoundColumn(); 
        boundColumn.DataField = "ParentID"
        boundColumn.HeaderText = "ParentID"
        RadGrid1.MasterTableView.Columns.Add(boundColumn); 
        RadGrid1.Skin = "Web20"
        RadGrid1.ClientSettings.AllowExpandCollapse = true
        RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client; 
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true
        RadGrid1.MasterTableView.DataKeyNames = new string[] { "ID""ParentID" }; 
        RadGrid1.MasterTableView.SelfHierarchySettings.ParentKeyName = "ID"
        RadGrid1.MasterTableView.SelfHierarchySettings.KeyName = "ParentID"
        form1.Controls.Add(RadGrid1); 
    } 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1) 
        { 
            RadGrid1.MasterTableView.FilterExpression = @"it[""ID""] = ''"
        } 
        else 
        { 
            RadGrid1.MasterTableView.FilterExpression = "ID = ''"
        } 
 
    } 
   
 
 


but I must be missing something or I do something wrong because there is no hierarchy once rendered.


Thanks



3 Answers, 1 is accepted

Sort by
0
pylacroix
Top achievements
Rank 1
answered on 28 Oct 2009, 12:46 PM
so, nobody knows or have any clue ?
0
Accepted
Mira
Telerik team
answered on 29 Oct 2009, 04:56 PM
Hi Pierre,

I am attaching a modification of your project to this post showing how the desired by you functionality can be implemented.

Please take a look at it and tell me whether you find it useful.

Sincerely yours,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
pylacroix
Top achievements
Rank 1
answered on 29 Oct 2009, 05:35 PM
thanks a lot.

Now, I just have to make it work as shown in http://www.telerik.com/community/forums/aspnet-ajax/grid/self-referencing-hierarchy-in-programmatic-grid.aspx
Tags
Grid
Asked by
pylacroix
Top achievements
Rank 1
Answers by
pylacroix
Top achievements
Rank 1
Mira
Telerik team
Share this question
or