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

[Solved] grid grouping error

3 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
steve
Top achievements
Rank 1
steve asked on 07 Dec 2009, 09:09 PM
I am trying to make a multi row column that has two column header (groups) and 3 rows. In the first row, the first column has 2 columns under it and the second column has two columns as well. but in the third row the first column is blank (or atleast looks that way to the user), the second column has three columns where on column belongs to on parent and the other 2 belong to the other column

+------------------------------------+----------------------------------------------------+     
|               Name                 |                   Location                         |     
+----------------+-------------------+--------------------------------+-------------------+     
|     fname      |       lName       |           address 1            |    address 2      |
+----------------+-------------------+---------------+----------------+-------------------+     
|                |                   |     street    |      state     |     country       |
+----------------+-------------------+---------------+----------------+-------------------+    
 

Is there a parent child relationship I am missing to get the second row under it's respected parent or is it another GridViewColumnGroup 


view.ColumnGroups.Add(new GridViewColumnGroup("Name"));  
view.ColumnGroups.Add(new GridViewColumnGroup("Location"));  
    
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[0].Rows[0].Columns.Add(radGridView1.Columns["fname"]);  
view.ColumnGroups[0].Rows[0].Columns.Add(radGridView1.Columns["lName"]);  
              
view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[1].Rows[0].Columns.Add(radGridView1.Columns["address 1"]); 
view.ColumnGroups[1].Rows[0].Columns.Add(radGridView1.Columns[
"address 2"]); 
view.ColumnGroups[1].Rows[1].Columns.Add(radGridView1.Columns["street"]);
view.ColumnGroups[1].Rows[1].Columns.Add(radGridView1.Columns["state"]); 
view.ColumnGroups[1].Rows[1].Columns.Add(radGridView1.Columns["country"]);  
 

3 Answers, 1 is accepted

Sort by
0
steve
Top achievements
Rank 1
answered on 07 Dec 2009, 09:22 PM
I guess my question is, How do you create subgroups to a groups.  I am going to loop through 2 datatables one holding the header info and the other will hold the data for the grid.
0
steve
Top achievements
Rank 1
answered on 07 Dec 2009, 09:55 PM
I figured it out!

view.ColumnGroups.Add(new GridViewColumnGroup("Name"));  
view.ColumnGroups.Add(new GridViewColumnGroup("Location"));  
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["fname"]);  
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["lName"]);  
 
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("address 1"));  
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("address 2"));  
view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());  
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(radGridView1.Columns["street"]);  
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(radGridView1.Columns["state"]);  
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(radGridView1.Columns["country"]);  
 
0
Svett
Telerik team
answered on 08 Dec 2009, 09:23 AM
Hello steve,

We are happy that you figured out the solution without assistance. If you have any questions regarding our products, do not hesitate to contact us back.

Kind regards,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
steve
Top achievements
Rank 1
Answers by
steve
Top achievements
Rank 1
Svett
Telerik team
Share this question
or