We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GridTableSummaryRow - Sum only positive values

Hi,

If there a way to only display the sum of positive values in the GridTableSummaryRow  ?

Regards,

1 Reply

GT Gnanasownthari Thirugnanam Syncfusion Team March 10, 2016 01:55 PM UTC

Hi Marquant,

We are analyzed your query. And you can achieve your requirement “only display the sum of positive values in GridTableSummaryRow” by using the CustomAgreegate like the below code example.

C#



public
class CustomAggregate:ISummaryAggregate

    {

        public CustomAggregate()

        {

        }

        public double PositiveSummation { get; set; }


        public Action<System.Collections.IEnumerable, string, System.ComponentModel.PropertyDescriptor> CalculateAggregateFunc()

        {

            return (items, property, pd) =>

            {

                var enumerableItems = items as IEnumerable<OrderInfo>;

               foreach(var item in enumerableItems)

               {

                   if(item.Discount>=0)

                   {

                       this.PositiveSummation += item.Discount;

                   }

               }              

            };
        }




We have prepared a sample as per your requirement and you can download the same from the below location,

Sample : http://www.syncfusion.com/downloads/support/forum/123356/ze/Summaries571578970

Please refer the below UG link to know more about the Custom Summaries,

Link : http://help.syncfusion.com/wpf/sfdatagrid/summaries




Regards,

Gnanasownthari T.



Loader.
Live Chat Icon For mobile
Up arrow icon