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

Aggregate to footer from boolean data

1 Answer 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Harri
Top achievements
Rank 1
Harri asked on 23 Apr 2015, 08:14 AM

Hi

I found many examples of custom aggregates and I'm able to do aggregate function with those helps for specific class with specific property which is used in my grid. But now I have few situations that I want to get count of checked (in class type boolean with value true) from that column. I would like to get it done in one function so I don't need to do several almost same kind code (only class and property changed).

So how I have to change this function to get it work universally (without class 'DeliveriesForAccountsCls' and property name 'isChecked')?

 

public class CheckedDeliveriesCount : AggregateFunction<DeliveriesForAccountsCls, double>
{
    public CheckedDeliveriesCount ()
    {
        this.AggregationExpression = items => Summary(items);
    }
 
    private double Summary(IEnumerable<DeliveriesForAccountsCls> source)
    {
        var itemCount = source.Count();
        if (itemCount > 1)
        {
            var values = source.Where(x => x.isChecked);
            var sum = values.Count();
            return sum;
        }
 
        return 0;
    }
}

 

 

Regards

Harri

 

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 24 Apr 2015, 12:53 PM
Hello Harri,

As it turns out there is not a more universal way of defining generic AggregateFunctions. All the accessible information is the one available with the arguments of the function. 

Regards,
Dimitrina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Harri
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or