Add custom function inside template

Stimulsoft Reports.WEB discussion
Post Reply
Werlang
Posts: 26
Joined: Wed Feb 20, 2013 1:50 pm

Add custom function inside template

Post by Werlang »

Hello

I have 2 questions:

1) How could we write a custom function to be used in a template? It can't be added to an assembly. The user can add her own function inside a template.

for example:

Code: Select all

public string MyFunc()
{
	return "XYZ";
}
2) How could we add custom code like the one above to StiReport? That would be the same for all reports, but the functions wouldn't exist in any compiled assembly.

Code: Select all

StiReport report = new StiReport();
report.CustomCode = "public string MyFunc() {return "XYZ";}";
report.Render();
TIA
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Add custom function inside template

Post by HighAley »

Hello.

Another way is to add assembly with this function to the Referenced Assemblies property of the report. You could do it with next code:

Code: Select all

List<String> refs = new List<string>(report.ReferencedAssemblies);

if (!refs.Contains("YourAssembly.dll"))
{
    refs.Add("YourAssembly.dll");
}
report.ReferencedAssemblies = refs.ToArray();
Thank you.
Werlang
Posts: 26
Joined: Wed Feb 20, 2013 1:50 pm

Re: Add custom function inside template

Post by Werlang »

Hello

But this functions doesn't exist in any assembly, I'd like to add function code inside template, so I could easily change it.

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Add custom function inside template

Post by Alex K. »

Hello,

Can you please clarify which designer do you use?
In standalone designer, you can open Code tab and add your function in report code.

Thank you.
Werlang
Posts: 26
Joined: Wed Feb 20, 2013 1:50 pm

Re: Add custom function inside template

Post by Werlang »

Aleksey wrote:Hello,

Can you please clarify which designer do you use?
In standalone designer, you can open Code tab and add your function in report code.

Thank you.
Hi Aleksey

It's MVC/Flash Designer.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Add custom function inside template

Post by Alex K. »

Hello,

Unfortunately, it is not possible for MVC/Flash Designer. Sorry.

Thank you.
Post Reply