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

Problem to Create Custom String Aggregate Function for GridView

9 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jignesh Sodvadiya
Top achievements
Rank 1
Jignesh Sodvadiya asked on 08 Jul 2015, 07:04 AM

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

Sort by
0
Dimitrina
Telerik team
answered on 08 Jul 2015, 08:42 AM
Hi Jignesh,

You can create a Generic AggregateFunction instead and return the result.

How does this work for you? 


Regards,
Dimitrina
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jignesh Sodvadiya
Top achievements
Rank 1
answered on 08 Jul 2015, 09:13 AM

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     

 

0
Dimitrina
Telerik team
answered on 13 Jul 2015, 08:51 AM
Hello Jignesh,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jignesh Sodvadiya
Top achievements
Rank 1
answered on 18 Jul 2015, 05:40 AM

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

 

 

 

 

0
Jignesh Sodvadiya
Top achievements
Rank 1
answered on 18 Jul 2015, 05:43 AM

Please find attached document.

M trying to send source but web site allow (.gif, .jpg, .jpeg, .png ) so I send Screen shot.

 

Thanks,

Jignesh

 

0
Dimitrina
Telerik team
answered on 20 Jul 2015, 07:22 AM
Hello Jignesh,

You can open a new support ticket through the ticketing system and attach it there. 

Regards,
Dimitrina
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jignesh Sodvadiya
Top achievements
Rank 1
answered on 20 Jul 2015, 08:38 AM

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

0
Dimitrina
Telerik team
answered on 21 Jul 2015, 07:18 AM
Hello,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jignesh Sodvadiya
Top achievements
Rank 1
answered on 21 Jul 2015, 08:24 AM

Hi,

I ​check your suggestion and that working Fine.

 

Thanks for your valuable post and suggestion.

 

Thanks,

Jignesh

 

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