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

[Solved] RadGrid Grouping

2 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
suria gade
Top achievements
Rank 1
suria gade asked on 06 Aug 2009, 10:57 PM
Hi-

I want to group the data in RadGrid but the layout I want to achieve is something like this below -

Country     State    County     zip

US               MS       Tate         1010
                               -------------------- 
                                clay          2102
                               ----------------------
                                 homles     3201
---------------------------------------------------
Japan         xxxx         yyyy          3243
                --------------------------------------
                   zzzz         qqqq          1234
                                ------------------------
                                  rrrr             3456
                                ------------------------  
                                  uyr              123             

Please let me know.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Aug 2009, 05:22 AM
Hello Suria,

I suppose you want to merge cells in your grid, if neighboring cells show equal values.In the example, if a cell value is the same as a value in the next (lower) row, then its RowSpan is increased and the lower cell is made invisible.
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
       for (int rowIndex = RadGrid1.Items.Count - 2; rowIndex >= 0; rowIndex--) 
        { 
            GridDataItem row = RadGrid1.Items[rowIndex]; 
            GridDataItem previousRow = RadGrid1.Items[rowIndex + 1]; 
 
            for (int i = 0; i < row.Cells.Count; i++) 
            { 
                if (row.Cells[i].Text == previousRow.Cells[i].Text) 
                { 
                    row.Cells[i].RowSpan = previousRow.Cells[i].RowSpan < 2 ? 2 : previousRow.Cells[i].RowSpan + 1; 
                    previousRow.Cells[i].Visible = false
                } 
            } 
 
        } 
   } 

Thanks
Princy.
0
suria gade
Top achievements
Rank 1
answered on 07 Aug 2009, 03:40 PM
Thanks princy. I will try it out the solution ..
Tags
Grid
Asked by
suria gade
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
suria gade
Top achievements
Rank 1
Share this question
or