Problem to Create Custom String Aggregate Function for GridView

10 posts, 0 answers
  1. Jignesh Sodvadiya
    Jignesh Sodvadiya avatar
    10 posts
    Member since:
    May 2010

    Posted 08 Jul 2015 Link to this post

    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

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 08 Jul 2015 Link to this post

    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
  3. DevCraft banner
  4. Jignesh Sodvadiya
    Jignesh Sodvadiya avatar
    10 posts
    Member since:
    May 2010

    Posted 08 Jul 2015 in reply to Dimitrina Link to this post

    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     

     

  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jul 2015 Link to this post

    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
  6. Jignesh Sodvadiya
    Jignesh Sodvadiya avatar
    10 posts
    Member since:
    May 2010

    Posted 18 Jul 2015 in reply to Dimitrina Link to this post

    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

     

     

     

     

  7. Jignesh Sodvadiya
    Jignesh Sodvadiya avatar
    10 posts
    Member since:
    May 2010

    Posted 18 Jul 2015 in reply to Jignesh Sodvadiya Link to this post

    Please find attached document.

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

     

    Thanks,

    Jignesh

     

  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Jul 2015 Link to this post

    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
  9. Jignesh Sodvadiya
    Jignesh Sodvadiya avatar
    10 posts
    Member since:
    May 2010

    Posted 20 Jul 2015 in reply to Dimitrina Link to this post

    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

  10. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 21 Jul 2015 Link to this post

    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
  11. Jignesh Sodvadiya
    Jignesh Sodvadiya avatar
    10 posts
    Member since:
    May 2010

    Posted 21 Jul 2015 in reply to Dimitrina Link to this post

    Hi,

    I ​check your suggestion and that working Fine.

     

    Thanks for your valuable post and suggestion.

     

    Thanks,

    Jignesh

     

Back to Top
DevCraft banner