Merging footer columns

7 posts, 2 answers
  1. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 03 Mar 2010 Link to this post

    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?


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2010 Link to this post


    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 04 Mar 2010 Link to this post

    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 

  5. Answer
    Cartoon Head
    Cartoon Head avatar
    21 posts
    Member since:
    Apr 2010

    Posted 17 Jun 2010 Link to this post

    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. 
  6. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 17 Jun 2010 Link to this post

    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!
  7. Answer
    Cartoon Head
    Cartoon Head avatar
    21 posts
    Member since:
    Apr 2010

    Posted 17 Jun 2010 Link to this post

    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?

  8. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 17 Jun 2010 Link to this post

    Nevermind, your suggestion worked perfectly.  I had a hidden column I wasn't accounting for.

    Thanks!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017