Add Summary Functions in runtime

Stimulsoft Reports.WEB discussion
Post Reply
jenny
Posts: 5
Joined: Tue Nov 22, 2016 1:26 pm

Add Summary Functions in runtime

Post by jenny »

Hello!
I have a .Net procedure where i add StiText Components to data column band in dynamic way like this:
dataCol = new StiText();
dataCol.GetValue += new Stimulsoft.Report.Events.StiGetValueEventHandler(
(sender, e) => { e.Value = p.GetValue(mainDataSource).ToString(); });
dataBand.Components.Add(dataCol);

I would like to add StiText Components with a summary function to a data footer band with code. I tried something like this

footerCol = new StiText();
footerCol .GetValue += new Stimulsoft.Report.Events.StiGetValueEventHandler(
(sender, e) => { e.Value = "#%#{Sum(GroupHeader,fieldname)}"});
footBand.Components.Add(footerCol );
However, this is not enough, as the function Sum is not recognised and report displays the exact text of Value.
How can i add summary functions in runtime?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Add Summary Functions in runtime

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

var footerCol = new StiText();
footerCol.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0.2, 0, 8.4, 1);
footerCol.Text = new StiExpression("{Sum(DataCategories, Categories.CategoryID)}");
var footBand = report.GetComponentByName("FooterBand1") as StiFooterBand;
footBand.Components.Add(footerCol);
report.Compile();
Thank you.
jenny
Posts: 5
Joined: Tue Nov 22, 2016 1:26 pm

Re: Add Summary Functions in runtime

Post by jenny »

Thank you for your response!
Unfortunately this didn't work, as i would like to add a column in runtime.
I suppose this is the answer why viewtopic.php?f=13&t=54071
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Add Summary Functions in runtime

Post by HighAley »

Hello.

Yes, if you do this at runtime, you should use the Totals class.

Thank you.
Post Reply