I am currently looking at the following demo,
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultvb.aspx
Which show how to build a hierarchial grid programmaticaly. The problem I have is that I wish to use a datatable populated from a stored procedure for the grids. I have tried the following,
The grid will expand to show the child table, however with no data. Any pointers would be much appreciated.
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/hierarchy/defaultvb.aspx
Which show how to build a hierarchial grid programmaticaly. The problem I have is that I wish to use a datatable populated from a stored procedure for the grids. I have tried the following,
Private Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Init buildGrid()End SubSub buildGrid() Dim state As String = drp_state.SelectedValue If state = "" Then state = 0 End If Dim dt As DataTable = myDataAccessClass.data1(param1, param2) Datasource = dt GridDataKeyNames = "ID" ' masterTableCreation builds and adds the columns, no issue with this. masterTableCreation() Dim dtSub As DataTable = myDataAccessClass.data1(param3) hierarchyTable(dtSub, "", "ID", "ID")End SubPublic Sub hierarchyTable(ByVal dt As DataTable, ByVal datakeys As String, ByVal masterKeyField As String, ByVal detailKeyField As String) Dim hierarchyTable As New GridTableView(RadGrid1) ' set the datasouce hierarchyTable.DataSource = dt hierarchyTable.Width = Unit.Percentage(100) Dim datakeysArray() As String If datakeys <> "" Then datakeysArray = datakeys.Split(",".ToArray()) hierarchyTable.DataKeyNames = datakeysArray End If Dim relationFields As GridRelationFields = New GridRelationFields() relationFields.MasterKeyField = masterKeyField relationFields.DetailKeyField = detailKeyField hierarchyTable.ParentTableRelation.Add(relationFields) RadGrid1.MasterTableView.DetailTables.Add(hierarchyTable) 'add columns Dim boundColumn As GridBoundColumn hierarchyTable.Columns.Clear() For i As Int32 = 0 To Datasource.Columns.Count - 1 Dim column As DataColumn = Datasource.Columns(i) Dim colDataType As String = column.DataType.ToString().ToLower().Replace("system.", "") boundColumn = New GridBoundColumn hierarchyTable.Columns.Add(boundColumn) boundColumn.DataField = column.ColumnName boundColumn.HeaderText = column.ColumnName.Replace("_", " ").ToLower() boundColumn.DataFormatString = "<nobr>{0}</nobr>" boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left NextEnd Sub<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" PageSize="5" GridLines="None" ShowGroupPanel="True"> <MasterTableView AllowMultiColumnSorting="True" GroupLoadMode="Server"> </MasterTableView> <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle> <ClientSettings AllowDragToGroup="true" /></telerik:RadGrid>The grid will expand to show the child table, however with no data. Any pointers would be much appreciated.