Dear All,
I am using Telerik Silverlight UI Control.
Once i has Create Custom Aggegate function for Number Type and Its working Fine but Now I needed String Aggegate function Code are Following.
Code :
public class RPT_CustomAggregates_Function : EnumerableSelectorAggregateFunction
{
protected override string AggregateMethodName
{
get
{
return "RPT_CustomAggregates";
}
}
protected override Type ExtensionMethodsType
{
get
{
return typeof(Statistics);
}
}
}
public static class Statistics
{
public static object RPT_CustomAggregates<T>(IEnumerable<T> source, Func<T, object> selector)
{
return "Hello";
}
}
This Code give Error on runtime.
No generic method 'RPT_CustomAggregates' on type 'Report_Config.Statistics' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
Please guide how to resolve this problem.
Thanks,
Jignesh
9 Answers, 1 is accepted
You can create a Generic AggregateFunction instead and return the result.
How does this work for you?
Regards,
Dimitrina
Telerik
Thanks for your Reply.
I want to compare Two Column Total like Cr. and Dr. and According to Diff. Display Diff. Amount with Cr. or Dr. Label.
Thanks
In case the approach illustrated on the demo does not work for you, would it be possible for you to demonstrate the setup you have in a sample project and send it to us? You can open a new support ticket and attach it there.
Regards,
Dimitrina
Telerik
Thanks for your Reply..
Please find attached Source code.
As per Source.
Dr. Amount Total =36000 and Cr. Amount Total=26000 and that Total displayed in Footer.
After that Cumu. Amount Column Manually calc.
As per Formula
Total Cumu. Amount = 10000 Dr. (36000 Dr. - 10000 Cr.)
Please reply.
Thanks,
Jignesh
Please find attached document.
M trying to send source but web site allow (.gif, .jpg, .jpeg, .png ) so I send Screen shot.
Thanks,
Jignesh
You can open a new support ticket through the ticketing system and attach it there.
Regards,
Dimitrina
Telerik
This is my string Aggregate Function Code :
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
Telerik.Windows.Data;
namespace
TestProject
{
public
class
RadDG_CustomAgg_CR_DR_SUM_Function : EnumerableSelectorAggregateFunction
{
protected
override
string
AggregateMethodName
{
get
{
return
"RadDG_CustomAgg_CR_DR_SUM"
;
}
}
protected
override
Type ExtensionMethodsType
{
get
{
return
typeof
(Aggregates);
}
}
}
public
static
class
Aggregates
{
public
static
string
RadDG_CustomAgg_CR_DR_SUM<TSource>(IEnumerable<TSource> source, Func<TSource,
object
> selector)
{
if
(source.Count() == 0)
return
"Test"
;
else
return
"Hello"
;
}
}
}
But It gives error at Runtime.
Please repl y.
Thanks,
Jignesh
I was able to reproduce the issue locally. As alternative solution, I would suggest you the following approach:
public
static
class
Aggregates
{
public
static
string
RadDG_CustomAgg_CR_DR_SUM<TSource>(IEnumerable<TSource> source, Func<TSource,
object
> selector)
{
if
(source.Count() == 0)
return
"Test"
;
else
return
"Hello"
;
}
}
public
class
GenericFunction : AggregateFunction<
object
,
string
>
{
public
GenericFunction()
{
this
.AggregationExpression = items => RadDG_CustomAgg_CR_DR_SUM(items);
}
private
string
RadDG_CustomAgg_CR_DR_SUM(IEnumerable<
object
> source)
{
if
(source.Count() == 0)
return
"Test"
;
else
return
"Hello"
;
}
}
Let me know how this works for you.
Regards,
Dimitrina
Telerik
Hi,
I ​check your suggestion and that working Fine.
Thanks for your valuable post and suggestion.
Thanks,
Jignesh