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

[Solved] gridrow with multiple values

2 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lkj lkj
Top achievements
Rank 1
lkj lkj asked on 18 Jan 2010, 11:19 AM
Hi

I have a gridview where my orders are listed. I need to have a list where my orderlines are displayed

like this

id    ordername        date                invoicelines
1    Order of plates  21-01-2010    line one bla bla bla
                                                      line two bla bla bla
                                                      line three bla bla bla

2    Order of Milke    25-01-2010    line one bla bla
                                                      line two bla bla


how can that be accomplished?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 18 Jan 2010, 01:03 PM
Hi,

You can merge cells in your grid, if neighboring cells have the same 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
                } 
            } 
 
        } 
   } 

Hope this helps..
Princy.
0
lkj lkj
Top achievements
Rank 1
answered on 18 Jan 2010, 01:05 PM
nice... thx
Tags
Grid
Asked by
lkj lkj
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
lkj lkj
Top achievements
Rank 1
Share this question
or