Problems getting agregate functions' values with RadTreeListView's column.getaggregateresults()

121 Views Asked by At

I am using a Count AggregateFunction and I would like to access it's value from the code behind. This task can be managed using the function getaggregateresults(QueryableCollectionViewGroup group) but I am having problems accessing the QueryableCollectionViewGroup object, because it's constructor is protected.

Here's the code that I am using:

   <GridViewDataColumn  UniqueName="NameHeader">                   
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:CountFunction Caption="Count: " />
                </telerik:GridViewDataColumn.AggregateFunctions>
    </GridViewDataColumn>`

The function call would be laike this:

this.RadTreeListView.Columns["NameHeader"].GetAggregateResults(QUERYABLEGROUP).ElementAt(0).FormattedValue;

I would appreciate any help.

Thanks in advance.

1

There are 1 best solutions below

0
On

I have managed to retrieve the answer executing this function when the RadTreeListView.DataLoaded event occurs:

    void UnselectedItemsDataGrid_DataLoaded(object sender, EventArgs e)
    {  
        var s = (RadTreeListView)sender;
        s.CalculateAggregates();
        AggregateResult result = s.AggregateResults[0];
    }

The RadTreeListView only has the Count aggregate function, so it always be at index 0. The result is wrapped on the AggregateResult. This code is an example, however it lights the path to a solution.

I hope this answer will be able to help if anyone has the same problem.