Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Hiding certain ColumnGroup Headers

$
0
0
Hello,

Thank you for writing.

You can use the ViewRowFormatting event and set the RowElement.MaxSize property for the GridViewTableHeaderRowInfo. Thus, only the groups on the first row will be displayed. Here is a sample code snippet:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim view As New ColumnGroupsViewDefinition()
    view.ColumnGroups.Add(New GridViewColumnGroup("Customer Contact"))
 
    view.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("x"))
    view.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("x"))
    view.ColumnGroups(0).Groups(0).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(0).Groups(1).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("ContactName"))
    view.ColumnGroups(0).Groups(1).Rows(0).Columns.Add(Me.RadGridView1.Columns("ContactTitle"))
    view.ColumnGroups.Add(New GridViewColumnGroup("Details"))
    view.ColumnGroups(1).Groups.Add(New GridViewColumnGroup("x"))
    view.ColumnGroups(1).Groups.Add(New GridViewColumnGroup("x"))
    view.ColumnGroups(1).Groups(0).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(1).Groups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("Address"))
    view.ColumnGroups(1).Groups(1).Rows.Add(New GridViewColumnGroupRow())
    view.ColumnGroups(1).Groups(1).Rows(0).Columns.Add(Me.RadGridView1.Columns("Phone"))
    RadGridView1.ViewDefinition = view
    Me.RadGridView1.BestFitColumns()
End Sub
 
Private Sub RadGridView1_ViewRowFormatting(sender As Object, e As RowFormattingEventArgs) Handles RadGridView1.ViewRowFormatting
    If TypeOf e.RowElement.RowInfo Is GridViewTableHeaderRowInfo Then
        e.RowElement.MaxSize = New Size(e.RowElement.Size.Width, 1)
    End If
End Sub

Note that it is just a sample approach and it may not cover all possible cases. Feel free to modify it on a way which suits your requirement best.

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

Viewing all articles
Browse latest Browse all 94857

Latest Images

Trending Articles



Latest Images