Hello all,
I want to generate hierarchy grid view with multiple levels like the picture http://screencast.com/t/L0snTsuj
Currently i use AutoGenerateHierarchy and create recursive data, i generated three levels like the picture http://screencast.com/t/ZtxNcwMqPaz
However i could not found any solutions for latest children template (different columns and data, grouping by columns, and only generate when parent expanded)
Please help me!!!
Thanks
Regards
9 Answers, 1 is accepted
Thank you for writing.
I would like to note that when you setup grid hierarchy, you add a template which is common for the entire child level. Hence, it uses common columns. However, in order to achieve your goal, you can add several child templates and display the relevant one (and hide the other/s) when expanding a master row. A sample approach is demonstrated in our Formatting Cells help article >> Example 4: Hiding child tabs when no data is section.
As to the grouping question, note that you can add a GroupDescriptor programmatically to the desired child GridViewTemplate. The following help article is quite useful on this topic: http://docs.telerik.com/devtools/winforms/gridview/grouping/setting-groups-programmatically
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Hi Dess,
Thanks for your helps!
However i think it so difficult implement and custom because everything are dynamic, so i use TableLayoutPanel to custom it.
Thanks
Regards
Dat
Thank you for writing back.
Feel free to use this approach which suits your requirements best. However, the recommended approach is to use two different child templates with the respective columns and show only one of the child templates at a time for the given parent row.
If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress
Hi Dess,
Thanks for your helps!
Thanks
Regards
Dat
But I have a problem, while hiding the tab that has no data, sometimes expands several rows at the same time, but in isolation, I can not find the pattern of error.
Thank you very much, excuse the English, is a translator, I speak Spanish.
Thank you for writing.
Would it be possible to provide a full code snippet reproducing the problem you are facing? In addition, a sample screenshot of the obtained and expected result would help us better understand the issue. A better option is to submit a support ticket where you can provide a sample project reproducing the problem.
Once we replicate the issue locally, we would be able to investigate the precise case and assist you further. Thank you in advance.
I am looking forward to your reply.
Regards,
Dess
Telerik by Progress
The code used is a copy of the example:
Private Sub radGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs) Dim cell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement) Dim expanderCell As GridGroupExpanderCellElement = TryCast(e.CellElement, GridGroupExpanderCellElement) If expanderCell IsNot Nothing AndAlso TypeOf e.CellElement.RowElement Is GridDataRowElement Then Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(expanderCell.RowInfo, GridViewHierarchyRowInfo) If Not IsExpandable(hierarchyRow) Then expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden Else expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible End If ElseIf cell IsNot Nothing Then Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(DirectCast(cell.RowInfo, GridViewDetailsRowInfo).Owner, GridViewHierarchyRowInfo) For i As Integer = 0 To cell.PageViewElement.Items.Count - 1 Dim item As RadPageViewItem = cell.PageViewElement.Items(i) Dim viewInfo As GridViewInfo = hierarchyRow.Views(i) item.Text = "Child Template " & i If viewInfo.ChildRows.Count = 0 Then If i = 0 AndAlso i < cell.PageViewElement.Items.Count - 1 Then cell.PageViewElement.Items(i + 1).IsSelected = True End If item.Visibility = Telerik.WinControls.ElementVisibility.Collapsed Else item.Visibility = Telerik.WinControls.ElementVisibility.Visible End If Next End IfEnd SubPrivate Function IsExpandable(hierarchyRow As GridViewHierarchyRowInfo) As Boolean For Each view As GridViewInfo In hierarchyRow.Views If view.ChildRows.Count > 0 Then Return True End If Next Return FalseEnd Function
I attach a gif image where you can see how RadGrid expands two or more rows when clicking.
Thank you very much
Martin.
Thank you for writing back.
I have logged it in our feedback portal and I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.
I have also updated your Telerik points.
Currently, the possible solution that I can suggest is to cancel expanding the incorrect row:
AddHandler Me.RadGridView1.ChildViewExpanding, AddressOf RadGridView1_ChildViewExpanding AddHandler Me.RadGridView1.MouseDown, AddressOf RadGridView_MouseDownPrivate Sub RadGridView1_ChildViewExpanding(sender As Object, e As ChildViewExpandingEventArgs) If lastClicked IsNot Nothing AndAlso e.ParentRow.Equals(lastClicked) Then e.Cancel = False Else e.Cancel = True End IfEnd SubDim lastClicked As GridViewRowInfoPrivate Sub RadGridView_MouseDown(sender As Object, e As MouseEventArgs) Dim expander As GridExpanderItem = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridExpanderItem) If expander IsNot Nothing Then lastClicked = DirectCast(expander.Parent, GridGroupExpanderCellElement).RowInfo End IfEnd SubI hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress
Thanks, your code worked perfectly.
Greetings.
