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

Grid Group

1 Answer 166 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stim24
Top achievements
Rank 1
Stim24 asked on 05 Sep 2019, 03:14 PM
How progamming grouping colum in radgridview?
I have this grid (picture "grid_now.jpg")
Need to do (picture "grid_needow.jpg")

Programm code :
this.columnGroupsView = new ColumnGroupsViewDefinition();<br><br>            this.columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("group1"));<br>            this.columnGroupsView.ColumnGroups[0].Groups.Add(new GridViewColumnGroup("h1"));<br>            this.columnGroupsView.ColumnGroups[0].Groups[0].Rows.Add(new GridViewColumnGroupRow());<br>            this.columnGroupsView.ColumnGroups[0].Groups[0].Rows[0].ColumnNames.Add("column1");<br>            this.columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("group2"));<br>            this.columnGroupsView.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("h1"));<br>            this.columnGroupsView.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());<br>            this.columnGroupsView.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("column2");<br>            this.columnGroupsView.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());<br>            this.columnGroupsView.ColumnGroups[1].Groups[0].Rows[1].ColumnNames.Add("column3");<br><br>            this.radGridView1.ViewDefinition = columnGroupsView;<br>
not work(

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 06 Sep 2019, 10:28 AM

Hello Tim,

There is no need to add the second groups. Here is how you can change the code:

public RadForm1()
{
    InitializeComponent();
    var columnGroupsView = new ColumnGroupsViewDefinition();
    columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("group1"));
    columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("group2"));

    columnGroupsView.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
    columnGroupsView.ColumnGroups[0].Rows[0].ColumnNames.Add("column1");
     
    columnGroupsView.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow() { MinHeight = 30 });
    columnGroupsView.ColumnGroups[1].Rows[0].ColumnNames.Add("column2");

    columnGroupsView.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow() { MinHeight = 30 });
    columnGroupsView.ColumnGroups[1].Rows[1].ColumnNames.Add("column3");

    this.radGridView1.ViewDefinition = columnGroupsView;

    radGridView1.Columns.Add("column1");
    radGridView1.Columns.Add("column2");
    radGridView1.Columns.Add("column3");


}

I hope this helps. Should you have any other questions, do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Stim24
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or