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

Formatting rows as summary

1 Answer 34 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 15 Mar 2015, 11:29 PM
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

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Mar 2015, 08:54 AM
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.

 
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or