Custom Aggregate Function

Stimulsoft Reports.NET discussion
Post Reply
ivar
Posts: 21
Joined: Tue Aug 04, 2015 11:41 am

Custom Aggregate Function

Post by ivar »

Hello,

I have registered a custom aggregate function using:

Code: Select all

StiOptions.Services.AggregateFunctions.Add(new SumMoneyFunctionService());
This aggregate function doesn't work when the report calculation mode is 'Interpretation'

Is there a way to make it work?

Regards, Ivar
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom Aggregate Function

Post by Lech Kulikowski »

Hello,

Please try to use the following code for adding custom functions:

Code: Select all

public class MyFunction
{
    private const string Category = "MyFuncCategory";

    public static string MyFunc(string value)
    {
        return value.ToUpper();
    }

    public static void RegisterFunctions()
    {
        var ParamNames = new string[1];
        var ParamTypes = new Type[1];
        var ParamDescriptions = new string[1];

        ParamNames[0] = "value";
        ParamDescriptions[0] = "Descriptions";
        ParamTypes[0] = typeof(string);

        Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
                                 typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
    }
}
Thank you.
ivar
Posts: 21
Joined: Tue Aug 04, 2015 11:41 am

Re: Custom Aggregate Function

Post by ivar »

Thanks,

I used that to add custom functions for expressions and it works.

But how do I add a function to sum multiple lines like in the screenshot?

Regards, Ivar
Attachments
Untitled.png
Untitled.png (18.96 KiB) Viewed 2215 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Custom Aggregate Function

Post by HighAley »

Hello,

Sorry, there is no way to do this.
Different report events are used for the calculations.
You could use the events to make your calculations.

Thank you.
ivar
Posts: 21
Joined: Tue Aug 04, 2015 11:41 am

Re: Custom Aggregate Function

Post by ivar »

ok, not really what I wanted to hear but thanks anyway.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Custom Aggregate Function

Post by HighAley »

Hello.

Anyway you have to add code to report events and there is no way to get it using the custom function.
As a way you could try to do it in our source code. It's available for purchase.

Thank you.
ivar
Posts: 21
Joined: Tue Aug 04, 2015 11:41 am

Re: Custom Aggregate Function

Post by ivar »

I'll see what I can achieve with the report events. The problem is that many reports would need this custom code and our customers wouldn't know how to edit them without breaking the report. But I can solve it by calculating the totals in the businessobjects beforehand so I have a workaround.

Source code is not really an option I'm afraid. As soon as we start adding our own code we have to maintain it. I already have thousands of lines of code to maintain. I rather use the library as-is as long as most of what we want to achieve is possible.

Thanks for the information.
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom Aggregate Function

Post by Lech Kulikowski »

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply