14 Answers, 1 is accepted
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 24 Nov 2010, 11:37 AM
Hi,
Yes, this is quite possible,.
Try this..
hope that helps, but let me know if you need more information.
Richard
Yes, this is quite possible,.
Try this..
Private Sub GridView_ViewCellFormatting(ByVal sender As Object, _ ByVal e As CellFormattingEventArgs) Handles GridView.ViewCellFormatting RemovePlusMinusSymbol(e.CellElement) End SubPrivate Sub GridView_ChildViewExpanding(ByVal sender As Object, _ ByVal e As ChildViewExpandingEventArgs) Handles GridView.ChildViewExpanding e.Cancel = Not IsRowExpandable(e.ParentRow) End SubPublic Shared Sub RemovePlusMinusSymbol(ByVal cellElement As GridCellElement) Dim cell As GridGroupExpanderCellElement = TryCast(cellElement, GridGroupExpanderCellElement) If cell IsNot Nothing AndAlso TypeOf cellElement.RowElement Is GridDataRowElement Then If Not IsRowExpandable(cell.RowInfo) Then cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden Else cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible End If End IfEnd SubPublic Shared Function IsRowExpandable(ByVal rowInfo As GridViewRowInfo) As Boolean If rowInfo.ChildRows IsNot Nothing AndAlso rowInfo.ChildRows.Count > 0 Then Return True End If Return FalseEnd Functionhope that helps, but let me know if you need more information.
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 24 Nov 2010, 11:51 AM
0
Sagar
Top achievements
Rank 1
answered on 24 Nov 2010, 12:47 PM
Hi,
Thanks for Replying, but the object "cell" does not have any value, neither it gets any value on clicking on any of the (expand/collapse)(+/-) button or any cell. I suppose that it should get a value when the +/- is clicked.
Please Help
thanks & Regards
Thanks for Replying, but the object "cell" does not have any value, neither it gets any value on clicking on any of the (expand/collapse)(+/-) button or any cell. I suppose that it should get a value when the +/- is clicked.
Please Help
thanks & Regards
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 24 Nov 2010, 12:54 PM
Hello,
Please can you try this in a new project. It's just a grid on a form.
Regards,
Richard
Please can you try this in a new project. It's just a grid on a form.
Imports System.Collections.Generic Imports Telerik.WinControls Imports Telerik.WinControls.UI Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim parentList As New List(Of Parent) parentList.Add(New Parent(1, "Bob")) parentList.Add(New Parent(2, "Mary")) parentList.Add(New Parent(3, "George")) parentList.Add(New Parent(4, "Hilda")) Me.RadGridView1.DataSource = parentList Me.RadGridView1.AutoGenerateHierarchy = True Me.RadGridView1.Columns("Children").IsVisible = False End Sub Private Sub GridView_ViewCellFormatting(ByVal sender As Object, _ ByVal e As CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting If TypeOf e.CellElement Is GridDetailViewCellElement Then DirectCast(e.CellElement, GridDetailViewCellElement).ChildTableElement.StretchHorizontally = False End If RemovePlusMinusSymbol(e.CellElement) End Sub Private Sub GridView_ChildViewExpanding(ByVal sender As Object, _ ByVal e As ChildViewExpandingEventArgs) Handles RadGridView1.ChildViewExpanding e.Cancel = Not IsRowExpandable(e.ParentRow) End Sub Public Shared Function IsRowExpandable(ByVal rowInfo As GridViewRowInfo) As Boolean Try If rowInfo.ChildRows IsNot Nothing AndAlso rowInfo.ChildRows.Count > 0 Then Return True End If Return False Catch ex As System.NullReferenceException Return True End Try End Function Public Shared Sub RemovePlusMinusSymbol(ByVal cellElement As GridCellElement) Dim cell As GridGroupExpanderCellElement = TryCast(cellElement, GridGroupExpanderCellElement) If cell IsNot Nothing AndAlso TypeOf cellElement.RowElement Is GridDataRowElement Then If Not IsRowExpandable(cell.RowInfo) Then cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden Else cell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible End If End If End Sub End Class #Region "Parent Class" Public Class Parent Private m_ParentId As Integer Private m_ParentName As String Public Sub New(ByVal id As Integer, ByVal name As String) m_ParentId = id m_ParentName = name End Sub Public Property ParentId() As Integer Get Return m_ParentId End Get Set(ByVal value As Integer) m_ParentId = value End Set End Property Public Property ParentName() As String Get Return m_ParentName End Get Set(ByVal value As String) m_ParentName = value End Set End Property Public ReadOnly Property Children() As List(Of Child) Get If Me.m_ParentId = 1 Then Dim childList As New List(Of Child) childList.Add(New Child(1, 1, "Baby Bob")) childList.Add(New Child(1, 2, "Little Bob")) childList.Add(New Child(1, 3, "Tiny Bob")) Return childList Else Return Nothing End If End Get End PropertyEnd Class#End Region #Region "Child Class" Public Class Child Private m_ParentId As Integer Private m_ChildId As Integer Private m_ChildName As String Public Sub New(ByVal parentId As Integer, ByVal id As Integer, ByVal name As String) m_ParentId = parentId m_ChildId = id m_ChildName = name End Sub Public Property ChildId() As Integer Get Return m_ChildId End Get Set(ByVal value As Integer) m_ChildId = value End Set End Property Public Property ParentId() As Integer Get Return m_ParentId End Get Set(ByVal value As Integer) m_ParentId = value End Set End Property Public Property ChildName() As String Get Return m_ChildName End Get Set(ByVal value As String) m_ChildName = value End Set End PropertyEnd Class#End Region Regards,
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 24 Nov 2010, 02:52 PM
Hi,
If this isn't working for you, I just wanted to confirm what version of the controls you are using. Let me know if this works for you, or you need more help.
Thanks
Richard
If this isn't working for you, I just wanted to confirm what version of the controls you are using. Let me know if this works for you, or you need more help.
Thanks
Richard
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 25 Nov 2010, 10:39 AM
Hello guys,
In adition to Richard's suggestion you may also want to take a look at this KB Article: Hide expand/collapse image in hierarchical RadGridView
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
In adition to Richard's suggestion you may also want to take a look at this KB Article: Hide expand/collapse image in hierarchical RadGridView
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 01:17 PM
Hi Sagar,
Did this help? If so, may I ask that you mark as answer all replies that helped so others can find the solution too. If you need more help, just let me know.
Regards,
Richard
Did this help? If so, may I ask that you mark as answer all replies that helped so others can find the solution too. If you need more help, just let me know.
Regards,
Richard
0
Sagar
Top achievements
Rank 1
answered on 26 Nov 2010, 02:13 PM
Hi, Richard .
Wow. It works smoothly, Thanks again. And ya I want to ask that, why i can see only up to 3 levels hierarchy. At 3rd Level i can see the Hierarchy's '+' sign but when i press the button i cant see the next level hierarchy. Is it the height issue, but then i can give static height, it should be not be a limit to user. Please help in this case..
Thanks & Regards
Wow. It works smoothly, Thanks again. And ya I want to ask that, why i can see only up to 3 levels hierarchy. At 3rd Level i can see the Hierarchy's '+' sign but when i press the button i cant see the next level hierarchy. Is it the height issue, but then i can give static height, it should be not be a limit to user. Please help in this case..
Thanks & Regards
0
Richard Slade
Top achievements
Rank 2
answered on 26 Nov 2010, 02:43 PM
Hello,
I'm glad that worked for you. Do you have a sample you can post that will replicate the 3 level issue? I will then happily take a look and see if I can find a solution for you.
Thanks Sagar.
Richard
I'm glad that worked for you. Do you have a sample you can post that will replicate the 3 level issue? I will then happily take a look and see if I can find a solution for you.
Thanks Sagar.
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 27 Nov 2010, 02:57 PM
Hello Sagar,
Having re-visited this post, I see that there was an issue with height in multi level hierarchy RadGridViews. Not sure if this is yet fixed, but have a look at this forum post
hope this helps, but let me know if you have further questions
Richard
Having re-visited this post, I see that there was an issue with height in multi level hierarchy RadGridViews. Not sure if this is yet fixed, but have a look at this forum post
hope this helps, but let me know if you have further questions
Richard
0
Sagar
Top achievements
Rank 1
answered on 29 Nov 2010, 05:50 AM
Hi, Richard.
Thanks again...Issue is solved.I cant mark this as answer , but i would like to recommend this as answer to my second question.
Thanks Again,
Sagar
Thanks again...Issue is solved.I cant mark this as answer , but i would like to recommend this as answer to my second question.
Thanks Again,
Sagar
0
Andrew Jackson
Top achievements
Rank 1
answered on 01 Dec 2010, 11:24 AM
How do you achieve this for 'load on demand'? Or is it impossible to do due to the nature of the data not known before load...
0
Richard Slade
Top achievements
Rank 2
answered on 01 Dec 2010, 01:27 PM
Hi Andrew,
Do you mean that you click on the parent row, and it then loads the data for that parent? If so, then I don't think this would be possible as far as I'm aware, as you would need the expander on each row and would have to try and click on it to know if there were rows as you pointed out.
The only way around I can think of is to load a tiny subset for the child template. Enough to know if there are rows, and then change the source on expand, but I think with all the performance enhancements in the newer versions of the grids, it may not be worthwhile.
Hope that helps
Richard
Do you mean that you click on the parent row, and it then loads the data for that parent? If so, then I don't think this would be possible as far as I'm aware, as you would need the expander on each row and would have to try and click on it to know if there were rows as you pointed out.
The only way around I can think of is to load a tiny subset for the child template. Enough to know if there are rows, and then change the source on expand, but I think with all the performance enhancements in the newer versions of the grids, it may not be worthwhile.
Hope that helps
Richard
0
Hello Sagar,
Thank you for writing.
In addition to Richard's post I just want to mention that Load on Demand works the following way - when you click the expander image it loads the necessary data and this is the time when it becomes clear whether there are child rows or not. So in order to have expand/collapse images only for rows that contain child rows, you have to load your data at the beginning which contradicts to Load on Demand.
I hope this helps.
Best wishes,
Stefan
the Telerik team
Thank you for writing.
In addition to Richard's post I just want to mention that Load on Demand works the following way - when you click the expander image it loads the necessary data and this is the time when it becomes clear whether there are child rows or not. So in order to have expand/collapse images only for rows that contain child rows, you have to load your data at the beginning which contradicts to Load on Demand.
I hope this helps.
Best wishes,
Stefan
the Telerik team
