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

[Solved] Rowspan in Radgrid

1 Answer 835 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shiza A V
Top achievements
Rank 1
Shiza A V asked on 08 Sep 2009, 06:47 AM
Is it possible to do  a row span to  a column in radgrid item row(not header row)?
It should look as follows:


__________________________________________________________
|Description                                            |                   target                        |
|__________________________________________________________|
|Description  1                                          |                   2 | 3 |
|                                       |                4 | 5 |
|                                       |                   7 | 9 |
_____________________________________________________________
|Description  1                                          |                5    | 94 |
|                                          |             6       | 8 |
|                                        |               7     | 3 |
______________________________________________________________

I can send you the screen shot of the format I need if needed. I added the table this way , since there is no way to post image in the thread.

Thanks

Shiza

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Sep 2009, 07:37 AM
Hello Shiza,

You can extend cells if its value is the same as a value in the next row cell, by increasing its RowSpan and making the next row cell invisible as shown below:
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]; 
            if (row["ColumnUniqueName"].Text == previousRow["ColumnUniqueName"].Text) 
            { 
                row["ColumnUniqueName"].RowSpan = previousRow["ColumnUniqueName"].RowSpan < 2 ? 2 : previousRow["ColumnUniqueName"].RowSpan + 1; 
                previousRow["ColumnUniqueName"].Visible = false
            } 
        } 
    } 

Hope this helps you..
-Princy.
Tags
Grid
Asked by
Shiza A V
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or