This is a migrated thread and some comments may be shown as answers.

Merge Cells

4 Answers 428 Views
GridView
This is a migrated thread and some comments may be shown as answers.
KUMARAN
Top achievements
Rank 1
KUMARAN asked on 02 Jan 2015, 01:23 PM
1.How to span the cells in the Grid as Row wise and Column Wise.

2.How to merge Child Template Headers using Column Groups.

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Jan 2015, 02:24 PM
Hello Kumaran,

Thank you for writing.

The row/column span/merge functionality in RadGridView is supported via ViewDefinitions. Please refer to the following article where you can find more information regarding this functionality and examples of how to achieve it: http://www.telerik.com/help/winforms/gridview-viewdefinitions-column-groups-view.html.

To set a view definition of a child template, simply use its ViewDefinition property:
radGridView1.Templates[0].ViewDefinition

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
KUMARAN
Top achievements
Rank 1
answered on 03 Jan 2015, 05:54 AM
Error While Grouping Child Template Header.


   Dim view As New ColumnGroupsViewDefinition()

        view.ColumnGroups().Add(New GridViewColumnGroup())

        view.ColumnGroups.Add(New GridViewColumnGroup("BRANCH DETAILS"))
        view.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("Branch"))
        view.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("Total"))

        view.ColumnGroups(0).Groups(0).Rows.Add(New GridViewColumnGroupRow)
        view.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGrid.Columns("Name"))

        view.ColumnGroups(0).Groups(1).Rows.Add(New GridViewColumnGroupRow)
        view.ColumnGroups(0).Groups(1).Rows(0).Columns.Add(Me.RadGrid.Columns("Quantity"))
        view.ColumnGroups(0).Groups(1).Rows(0).Columns.Add(Me.RadGrid.Columns("Value"))
        
        Me.RadGrid.MasterTemplate.ViewDefinition = view
        //Above Code is Working
        
        Dim view2 As New ColumnGroupsViewDefinition()
        view2.ColumnGroups().Add(New GridViewColumnGroup())

        view2.ColumnGroups.Add(New GridViewColumnGroup("Group Details"))
        view2.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("Group Total"))
        
        view2.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow)
        view2.ColumnGroups(0).Groups(0).Rows.Add(New GridViewColumnGroupRow)
        view2.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGrid.Columns("Quantity"))
        view2.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGrid.Columns("Value"))

        //Showing Error here '' Argument was out of rangeException Handled
                             '' Index was out of range. Must be non-negative and less than the size of the collection.
                              '' Parameter name: index  
        RadGrid.MasterTemplate.Templates(0).ViewDefinition = view2


       
0
KUMARAN
Top achievements
Rank 1
answered on 04 Jan 2015, 06:24 AM
Why I Didn't get answer yet.
0
Stefan
Telerik team
answered on 05 Jan 2015, 09:49 AM
Hello Kumaran,

Thank you for writing back.

The exception is most probably caused by the fact you are adding columns from the master level, to the child level's view definition
view2.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGrid.Columns("Quantity"))
view2.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGrid.Columns("Value"))

Here is an example of this working for both master and child levels:
Dim RadGrid As RadGridView
 
Protected Overrides Sub OnLoad(e As EventArgs)
    MyBase.OnLoad(e)
 
    RadGrid = New RadGridView
    RadGrid.Parent = Me
    RadGrid.Dock = DockStyle.Fill
    'first level
    RadGrid.Columns.Add("Name")
    RadGrid.Columns.Add("Quantity")
    RadGrid.Columns.Add("Value")
 
    RadGrid.Rows.Add("Name1", 11, 111)
 
    'child level
    Dim template As New GridViewTemplate()
    template.Columns.Add("ChildName")
    template.Columns.Add("ChildQuantity")
    template.Columns.Add("ChildValue")
    RadGrid.Templates.Add(template)
 
    Dim relation As New GridViewRelation(RadGrid.MasterTemplate)
    relation.ChildTemplate = template
    relation.ParentColumnNames.Add("Name")
    relation.ChildColumnNames.Add("ChildName")
    RadGrid.Relations.Add(relation)
 
    template.Rows.Add("Name1", 22, 33)
    template.Rows.Add("Name1", 33, 55)
    template.Rows.Add("Name1", 66, 22)
 
    'view defs
    Dim view As New ColumnGroupsViewDefinition()
 
    view.ColumnGroups().Add(New GridViewColumnGroup())
 
    view.ColumnGroups.Add(New GridViewColumnGroup("BRANCH DETAILS"))
    view.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("Branch"))
    view.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("Total"))
 
    view.ColumnGroups(0).Groups(0).Rows.Add(New GridViewColumnGroupRow)
    view.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGrid.Columns("Name"))
 
    view.ColumnGroups(0).Groups(1).Rows.Add(New GridViewColumnGroupRow)
    view.ColumnGroups(0).Groups(1).Rows(0).Columns.Add(Me.RadGrid.Columns("Quantity"))
    view.ColumnGroups(0).Groups(1).Rows(0).Columns.Add(Me.RadGrid.Columns("Value"))
 
    Me.RadGrid.MasterTemplate.ViewDefinition = view
    'Above Code is Working
 
    Dim view2 As New ColumnGroupsViewDefinition()
    view2.ColumnGroups().Add(New GridViewColumnGroup())
 
    view2.ColumnGroups.Add(New GridViewColumnGroup("Group Details"))
    view2.ColumnGroups(0).Groups.Add(New GridViewColumnGroup("Group Total"))
 
    view2.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow)
    view2.ColumnGroups(0).Groups(0).Rows.Add(New GridViewColumnGroupRow)
    view2.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGrid.Templates(0).Columns("ChildQuantity"))
    view2.ColumnGroups(0).Groups(0).Rows(0).Columns.Add(Me.RadGrid.Templates(0).Columns("ChildValue"))
 
    RadGrid.MasterTemplate.Templates(0).ViewDefinition = view2
End Sub

As to the question why you "did not get and answer yet", please note that although we monitor our forums very closely, and we strive to address our customers inquiries in the forums as well, the response time for the forums is usually 72 hours on business days. So if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread (usually within 24 hours).

Thank you for your understanding and I hope that you find the above information useful.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
KUMARAN
Top achievements
Rank 1
Answers by
Stefan
Telerik team
KUMARAN
Top achievements
Rank 1
Share this question
or