Hi, I have RadGrind 2009 Q1 with 4 levels of hierarchy. The GridTableView #3 is driven by a stored procedure that does own logic and routs select from different tables. Consequentially dataset for the level # 3 will have different columns for each row level # 2. The GridTableView #3 has AutoGenerateColumns="true".
Now, the problem that I have is that the RadGrid looks like stick to the columns headers of the first expended row at the level #3. The data (amount of rows) does come from the stored procedure proporly but the headers and the DataField for the AutoGenerateed Columns does not get overridden dynamically.
Could you help p me to address this problem?
4 Answers, 1 is accepted
One possible option in this case would be to use the DetailTableDataBind event handler. There, you can determine the level of the hierarchy, and pass the appropriate data.
I hope this suggestion gets you started properly.
All the best,
Pavlina
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.
Pavlina, of course I use the DetailTableDataBind event but I am sure you understand what I ask. In my case each level of hierarchy has completely different datastructure (columns, type etc) and they are different from row to row. Your grid looks like willing to have all rows of the same hierarchy driver by the same SQL. This is what I need:
Cat | Dog | Elephant | Horse | Monkey |
Green | Yellow | Blue| Orange | Red |
Pig | Porcupine | Pterodactyl | Snake | Cow |
Triangle | Circle | Square |
| Case "Detail3" |
| 'get ref key |
| Dim BillingRefID As String = dataItem.GetDataKeyValue("BillingRefID").ToString() |
| 'get data |
| Dim DataTable As DataTable = GetDataTable("exec DrilDown_Level_3_Get '" & BillingRefID + "'") |
| ' the <NoRecordsTemplate> does not work at EACH GridTableView layer, so do it ‘stupidly’ |
| If DataTable.Rows.Count = 0 Then |
| e.DetailTableView.DataSource = GetDataTable("Select '<FONT color=red size=2 >No further details available</FONT>' as ' '") |
| Return |
| End If |
| 'kill any opened row at the same level as it is possible that the new row will have a different header. |
| For Each item As GridDataItem In grdLevel1.Items |
| Dim pName As String = item.OwnerTableView.Name |
| If pName = "Detail2" Then |
| If dataItem.KeyValues <> item.KeyValues Then |
| item.Expanded = False |
| End If |
| End If |
| Next |
| Dim Name As String |
| Dim i As Integer = 0 |
| 'Override the header of the new layer with respect to the dataset – would LOVE to have the autogenerated worked for the EACH ROW |
| For i = 0 To DataTable.Columns.Count - 1 |
| Name = DataTable.Columns(i).ColumnName() |
| Dim boundColumn As GridBoundColumn |
| boundColumn = New GridBoundColumn() |
| boundColumn.UniqueName = Name |
| boundColumn.DataField = Name |
| boundColumn.HeaderText = Name |
| e.DetailTableView.Columns.Add(boundColumn) |
| Next |
| ' dump the data to the layer |
| e.DetailTableView.DataSource = DataTable |
Currently I do not run AutoGenerateColumns but override them manually but what I got to next level after manual levels then I have no event for parent DetailTable. Is it possible to escalate this question?
Rgs, Roman
Is it possible someone technical from support team to review this subject? I need to move forward with is and if RadGrid is not able to handle override of headers or not expose binding event at the parent level then I would not use the RadGrid for the task.
Please note that at the same level of hierarchy GridView has the same structure. In order to change the header text you could handle on ItemDataBound or PreRender event. For more information, please review the following links:
Accessing cells and rows
Traversing detail tables/items in Telerik RadGrid
Additionally, to create the grid dynamically you should handles on PageInit and calling its constructor. Please refer to the following help articles for additional information:
Programmatic creation(Create hierarchical grid programmatically section)
Changing the grid structure dynamically on postback
I hope this information helps.
Pavlina
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.