Page 1 of 1
Add custom function inside template
Posted: Tue Feb 11, 2014 12:26 am
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
Re: Add custom function inside template
Posted: Tue Feb 11, 2014 5:40 am
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.
Re: Add custom function inside template
Posted: Thu Feb 13, 2014 2:12 am
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
Re: Add custom function inside template
Posted: Fri Feb 14, 2014 6:08 am
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.
Re: Add custom function inside template
Posted: Sat Feb 15, 2014 1:16 am
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.
Re: Add custom function inside template
Posted: Mon Feb 17, 2014 6:16 am
by Alex K.
Hello,
Unfortunately, it is not possible for MVC/Flash Designer. Sorry.
Thank you.