Formatting rows as summary

2 posts, 0 answers
  1. Jason
    Jason avatar
    18 posts
    Member since:
    Aug 2014

    Posted 15 Mar 2015 Link to this post

    I am using a grid with bound rows and a summary row.  I would like to also format one of the bound rows to look like a summary row.
    Is there a simple way to do this?

    I've tried setting the cell element ThemeRole to "GridSummaryCellElement" in the CellFormatting event, but it didn't work
  2. Dess
    Admin
    Dess avatar
    1608 posts

    Posted 18 Mar 2015 Link to this post

    Hello Jason,

    Thank you for writing.

    In order to achieve your goal, you can use the RowFormatting event and apply custom formatting to RadGridView's data rows. Summary row elements have specific BackgroundShape. Here is a sample code snippet demonstrating how to extract the RadImageShape from the theme and set it to a specific data row by using the RowFormatting event:
    RadImageShape shape = null;
     
    private void Form1_Load(object sender, EventArgs e)
    {
        Theme theme = ThemeRepository.FindTheme("ControlDefault");
        StyleRepository rowRepository = theme.FindRepository("GridSummaryRowImageShape");
        shape = rowRepository.FindSetting("BackgroundShape").Value as RadImageShape;
     
        GridViewSummaryItem summaryItem = new GridViewSummaryItem();
        summaryItem.Name = "CategoryName";
        summaryItem.Aggregate = GridAggregateFunction.Count;
     
        GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
        summaryRowItem.Add(summaryItem);
     
        this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
        this.radGridView1.SummaryRowsBottom.Add(summaryRowItem);
     
        this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);
    }
     
    private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
    {
        if (e.RowElement.RowInfo.Index == 3 && shape != null)
        {
            e.RowElement.BackgroundShape = shape;
        }
        else
        {
            e.RowElement.ResetValue(LightVisualElement.BackgroundShapeProperty, ValueResetFlags.Local);
        }
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top