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

GridViewSummaryRowItem not working

1 Answer 94 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
Matias
Top achievements
Rank 1
Matias asked on 24 Oct 2017, 08:51 PM

Hi,

I have a custom view which calculates this way:

select ID, Name, Stock, (CASE WHEN Formato.Nombre = '25 gramos' THEN Cantidad END) AS [25 Gramos], 
                         (CASE WHEN Formato.Nombre = '50 gramos' THEN Cantidad END) AS [50 Gramos]
From products

That I populate into a GridView, no issues. Now.. when I try to add a GridViewSummaryRowItem to the rows [25 Gramos] and [50 Gramos] then it doesn't show up.

     GridViewSummaryItem summaryItem50 = new GridViewSummaryItem("50 Gramos", "Total 50 Gramos: {0}", GridAggregateFunction.Sum);

            GridViewSummaryItem summaryItem25 = new GridViewSummaryItem("25 Gramos", "Total 25 Gramos: {0}", GridAggregateFunction.Sum);

            GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
            summaryRowItem.Add(summaryItem50);
            summaryRowItem.Add(summaryItem25);

The code works because if I replace any of the 2 by Stock it shows up.

Is it because the View is constructed this way using CASE that the grid doesn't show the summary items?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Oct 2017, 09:59 AM
Hello, Matias,

Thank you for writing.  

When you add a GridViewSummaryItem, note that it is necessary to specify the Name of the column which should be aggregated. This column must be present in RadGridView. Otherwise, RadGridView won't be able to extract the cell's value and calculated the summary result. That is why the column that participates in the summary rows must be also included in the query. Thus, the summary row will be displayed at the bottom of the column.

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

Regards,
Dess
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.
Tags
DataGrid
Asked by
Matias
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or