Change # of columns in radgrid footer / footer template

4 posts, 0 answers
  1. ToltingColtAcres
    ToltingColtAcres avatar
    96 posts
    Member since:
    Nov 2010

    Posted 01 Dec 2015 Link to this post

    I have a three-level master/detail radgrid (think: Bill of Materials application with "Item", "Assembly", "Part").

    In the ItemDataBound event for the grid, I am capturing various metrics for each GridDataItem which I am then converting into a text value. The purpose is to give the operator some detailed information for each of the levels (e.g. "based on current inventory levels, we can only produce 5 of this assembly before Part ### is exhausted")

    I have been attempting, without success, to customize the radgrid's footer for each level in order to display this information. Also in the itemDataBound event, the event item is a GridFooterItem, I attempt to customize the footer to display this information. I have attempted to do this a couple of ways, based on various forum postings.

    One way that "works" is I change the text value of the first column (column #2, as column #0 = expand Column and column #1 = rowindicator column in the grid). I also set the columnspan value to reflect the total # of columns less 2 (for #'s 0 & 1). E.g.:

    footeritem["column2"].ColumnSpan = 8;
    footeritem["column2"].Text = my-String-field;


    I say this works, because, it does "work" (e.g. the data is displayed correctly for the footer), except, it "breaks" the layout of the grid in such a way that each of the levels' columns are no longer fully justified to the left and right sides of the grid. What I end up with is a grid where each detail level's data is displayed as "ragged right". It appears what happens is each column, at each level, in the grid is set to the absolute minimum amount of space needed to display the value.

    Removing the ColumnSpan directive results in the grid being laid out properly (e.g. all columns dynamically sized to make the grid at all 3 levels fully justified to the right and left.) However, since column#2 might be only, say, 100 pixels, I end up with 5-10 "lines" of wrapped text containing my string field, which is not very professional looking.


    Question: Is there a way to create a custom footer template for the radgrid with a single "column" which will be laid out correctly; that is, I could have a single column which spans the entire width of the radgrid so I can populate it with my text value, and not "break" the full justification of the grid?

  2. ToltingColtAcres
    ToltingColtAcres avatar
    96 posts
    Member since:
    Nov 2010

    Posted 02 Dec 2015 Link to this post

    A couple of followup pics... The first picture shows the effect of adding the "ColumnSpan" parameter, which does allow my text to span multiple columns in the footer, but then messes up the formatting of the grid on the right.

    The 2nd shows how everything is nicely formatted when not using ColumnSpan, but, I'd like to be able to get the text shown in the 3rd picture to span across the entire row as if all the columns were spanned together. 

    Any assistance on how I can accomplish this would be appreciated.
  3. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 04 Dec 2015 Link to this post


    You need to ensure that you are setting the correct ColSpan to the TableCell and that you are preventing the other cells from rendering:
    int colCount = 0;
    foreach (GridColumn column in filterItem.OwnerTableView.RenderColumns)
        if (column.UniqueName != "ExpandColumn" && column.UniqueName != "RowIndicatorColumn")
            TableCell cell = filterItem[column.UniqueName];
            cell.Visible = false;
    filterItem["column2"].ColumnSpan = colCount;
    filterItem["column2"].Text = "test";
    filterItem["column2"].Visible = true;

    Hope this helps.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. ToltingColtAcres
    ToltingColtAcres avatar
    96 posts
    Member since:
    Nov 2010

    Posted 06 Dec 2015 Link to this post

    I found setting visibility on the cells only resulted in me getting the "jagged right" output rather than the fully-justified output which makes the grid look like and professional.

    Based on some other posts I found on the 'net, I did this, which worked:

    GridFooterItem fitem = (GridFooterItem)e.Item;
    fitem["Cell2"].Text = mytestmessage;
    fitem["Cell10"].Text =  anothertestmessage;
    fitem.Cells[2].ColumnSpan = 8;

Back to Top