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

Determine active summary row

4 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 10 Nov 2017, 09:42 PM

I want to apply formatting to a cell in a summary row (or the entire row in some cases) but I have several summary rows in my grid. How can I tell in the viewrowformatting or other event which summary row is active?

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 13 Nov 2017, 09:44 AM
Hi Jeff,

You can use the following code to style a specific item:
private void RadGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
{
    if (e.RowElement.RowInfo is GridViewSummaryRowInfo)
    {
        var row = e.RowElement.RowInfo as GridViewSummaryRowInfo;
        if (row.SummaryRowItem[0].Name == "Freight")
        {
            
        }
    }
}

Please note that for summary cells/rows you need to use the ViewRowFormatting and ViewCellFormatting events.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jeff
Top achievements
Rank 1
answered on 13 Nov 2017, 06:33 PM

Thanks, Dimitar. I'm not sure I see in your code how to only perform an action if only a certain summary row is active.I am looking for something that let's me do something like this (assume I have 2 summary rows):

Here is the p-code:

If summaryrow is the first one of the two then set the backcolor to yellow

or

If summaryrow is the second one then set the "Freight" cell ONLY IN THAT SUMMARY ROW to a blue forecolor

Your comment suggests that each SummaryRowItem has a unique name, but I thought the name referred to the column to summarize. Is that not correct?

0
Dimitar
Telerik team
answered on 14 Nov 2017, 09:45 AM
Hello Jeff,

If you need to change the styles of a single cell you should use the ViewCellFormatting event. I have prepared a small example that shows how you can achieve the desired styling. 

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jeff
Top achievements
Rank 1
answered on 14 Nov 2017, 04:53 PM
Thanks, Dimitar. That gave me what I was looking for.
Tags
GridView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or