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

Merging footer columns

6 Answers 395 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 03 Mar 2010, 10:35 PM
I found many threads on merging, but couldn't seem to find one related to what I'm trying to do.

Seems like this code should work, but it doesn't.  What am I doing wrong?

    Protected Sub rgCart_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgCart.ItemCreated 
        If e.Item.ItemType = GridItemType.Footer Then 
            e.Item.Cells.RemoveAt(0) 
            e.Item.Cells(2).ColumnSpan = 2 
        End If 
    End Sub 

The cell removes correctly, but the merge does not occur.  Does this work in a RadGrid?


6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Mar 2010, 07:58 AM

Hi,

Please refer to the following code library link . I hope the approach provided there helps. 
http://www.telerik.com/community/code-library/aspnet-ajax/grid/span-cells-in-grid-over-multiple-positions.aspx

Hope this helps.
Princy
0
Matt
Top achievements
Rank 1
answered on 04 Mar 2010, 03:13 PM
Tried that solution, but it doesn't seem to affect the header or footer rows.  I'm trying to modify the footer row.  Any other ideas?

I tried this code and it works for all data rows, but not the header or footer rows...

    Protected Sub rgCart_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles rgCart.PreRender 
        For Each dgItem As GridDataItem In rgCart.MasterTableView.Items 
            dgItem.Cells(7).ColumnSpan = 2 
            dgItem.Cells(8).Visible = False 
        Next 
    End Sub 

0
Accepted
Cartoon Head
Top achievements
Rank 1
answered on 17 Jun 2010, 05:33 PM
This works for headers, I'm sure it works for footers too:

    Protected Sub grdYourGrid_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdYourGrid.PreRender  
 
        'Combine the 3 header cells for results  
        Dim grdHeader As GridHeaderItem = CType(grdYourGrid.MasterTableView.GetItems(GridItemType.Header)(0), GridHeaderItem)  
        grdHeader("ColumnToSpan").ColumnSpan = 3 
        grdHeader("ColumnToHide1").Visible = False 
        grdHeader("ColumnToHide2").Visible = False 
 
        grdHeader("ColumnToSpan").Text = "Spanned Header" 
 
    End Sub 

Just replace Header with Footer. 
0
Matt
Top achievements
Rank 1
answered on 17 Jun 2010, 09:00 PM
Thanks for the post.  I just tried it and it halfway works for me.  I was able to set the columns to not visible, but the first column does not stretch over the hidden columns.  Even if I use colspan=5.  It just stays in the 1st column of the grid.

Any thoughts?  Thanks!
0
Accepted
Cartoon Head
Top achievements
Rank 1
answered on 17 Jun 2010, 09:05 PM
Hmm.  I do know that I had to use this piece of code, because otherwise it seemed to ignore the existing text in the first column (the one being spanned):

        grdHeader("ColumnToSpan").Text = "Spanned Header"  

So maybe there's something else going on as well?

0
Matt
Top achievements
Rank 1
answered on 17 Jun 2010, 09:28 PM
Nevermind, your suggestion worked perfectly.  I had a hidden column I wasn't accounting for.

Thanks!
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Matt
Top achievements
Rank 1
Cartoon Head
Top achievements
Rank 1
Share this question
or