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

[Solved] Programatically dealing with Aggregate Functions

2 Answers 255 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mike massing
Top achievements
Rank 1
mike massing asked on 30 Apr 2009, 04:10 AM
Hello Telerik team,

I have a requirements  in my project w.r.t Aggregators as numbered below:

1.The caption for the count function need to be localized. Hence, i need a way by which i can specify it programatically. 
2. Currently with the code-block below, I can acheive something like: "Total: 12". 
 say if i want to acheive something like : Total: (12)  [Note the extra braces enclosed the numbers], is there a way to do it?

<Telerik:RadGridView.GroupDescriptions>
                <data:RadGroupDescription PropertyName="serialnumber" SortDirection="Ascending">
                    <data:RadGroupDescription.AggregateFunctions>
                        <data:CountFunction FunctionName="TotalCustomers" SourceField="serialnumber"
                                Caption="Total:" />
                    </data:RadGroupDescription.AggregateFunctions>
                </data:RadGroupDescription>
            </Telerik:RadGridView.GroupDescriptions>

Pls let me know about the options...

Regards
Mike

2 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 01 May 2009, 01:55 PM
Hello mike massing,

There is no problem to localize the function caption since you can give it any value form xaml.
Our next relase will add a ResultFormatString property our aggregate functions that will allow you to modify the result of a function in any way.

Since that feature is not available in our latest relase I have created a workaround that you can use. I have implemented a very simple AggregateWrapper function that wraps an existing function and displays its data using a format string.
<data:RadGroupDescription PropertyName="Size">     
    <data:RadGroupDescription.AggregateFunctions>    
        <local:AggregateWrapper Caption="Sum: "      
                                FunctionName="name"      
                                SourceField="Size"      
                                ResultFormatString="[{0}]">     
            <local:AggregateWrapper.Function>    
                <data:SumFunction />             
            </local:AggregateWrapper.Function>    
        </local:AggregateWrapper>    
    </data:RadGroupDescription.AggregateFunctions>    
</data:RadGroupDescription>    
 

The wrapper function has a property ResultFromatString that you can use to format the output of any aggregate function. In your case you should use "[{0}]".



Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
mike massing
Top achievements
Rank 1
answered on 02 May 2009, 03:59 AM
Hello Milan,

Thanks for your reply and  code. 
I now see it working. 

Regards
Mike
Tags
GridView
Asked by
mike massing
Top achievements
Rank 1
Answers by
Milan
Telerik team
mike massing
Top achievements
Rank 1
Share this question
or