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
Here is the code which is very similar that the one in the other post
but I must be missing something or I do something wrong because there is no hierarchy once rendered.
Thanks
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" 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