Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Stimulsoft Reports.Silverlight discussion
Locked
MartinB
Posts: 15
Joined: Wed May 02, 2012 11:02 am

Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by MartinB »

Hi, I am creating a label report via code and want to hide the label container panel based on the value of a variable. But it does not work and the panel always shows when the report is displayed in either the Silverlight viewer or designer/preview. If I save the report and then load in the stand-alone designer it works and the first 4 labels are hidden. Below is part of the code I am using, and I have attached the saved report:

StiDataBand objDataBand = new StiDataBand();
objDataBand.Height = LabelDefinition.Style.LabelStyle_LabelPitchVertical;
objDataBand.Name = "DataBand";
objDataBand.BusinessObjectGuid = ReportDefinition.Dictionary.BusinessObjects[0].Guid;
objDataBand.Columns = intCols;
objDataBand.ColumnWidth = LabelDefinition.Style.LabelStyle_LabelWidth;
objDataBand.ColumnDirection = StiColumnDirection.AcrossThenDown;
objDataBand.ColumnGaps = LabelDefinition.Style.LabelStyle_LabelPitchHorizonal - LabelDefinition.Style.LabelStyle_LabelWidth;
objReportPage.Components.Add(objDataBand);

StiPanel objLabelArea = new StiPanel(new RectangleD(0,0,LabelDefinition.Style.LabelStyle_LabelWidth,LabelDefinition.Style.LabelStyle_LabelHeight));
objLabelArea.Name = "LabelArea";
objDataBand.Components.Add(objLabelArea);

objDataBand.BeforePrintEvent.Script = "LabelArea.Enabled = (StartLabel <= 0)";
objDataBand.AfterPrintEvent.Script = "StartLabel--";


I have also tried enclosing StartLabel in {} but that did not work either.

I would be grateful for you could tell me what I am doing wrong?
Attachments
1892.Report.mrt
(8.76 KiB) Downloaded 586 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by Alex K. »

Hello,

Please try to disable labels in conditions instead a code.
Also can you please send us a sample project with test data for analysis.

Thank you.
MartinB
Posts: 15
Joined: Wed May 02, 2012 11:02 am

Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by MartinB »

Hi,

Pleae find attached a sample project which demonstrates the problem.

The label report is generated entily in code. I want to start printing labels at a set row and column, a variable (StartLabel) is added which in my live application is calculated as ((Start label row - 1) * No of labels across) + (Start label column - 1)
e.g. No of labels across: 3, Start row: 2, Start column: 2 = Skip the first 4 labels (StartLabel = 4)

In the DataBand before print event I want to set the LabelArea.Enabled = false when StartLabel is greater than 0
objDataBand.BeforePrintEvent = new Stimulsoft.Report.Events.StiBeforePrintEvent("LabelArea.Enabled = ({StartLabel} <= 0)");

In the DataBand after print event I want to decrement StartLabel
objDataBand.AfterPrintEvent = new Stimulsoft.Report.Events.StiAfterPrintEvent("{StartLabel}--");

As you will see in the attached project, neither the BeforePrintEvent or AfterPrintEvent seem to execute.
Attachments
1985.ReportTest.zip
(91.76 KiB) Downloaded 376 times
MartinB
Posts: 15
Joined: Wed May 02, 2012 11:02 am

Re: Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by MartinB »

Can anyone please help with this?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by Alex K. »

Hello,

Your solution working for client-server version. But native silverlight version has not compilation and events does not working.
In this case, you need to use conditions.

Thank you.
MartinB
Posts: 15
Joined: Wed May 02, 2012 11:02 am

Re: Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by MartinB »

Thanks Aleksey.

This worked:
objLabelArea.Conditions.Add(new StiCondition() { Column = "Students.BarcodeNumber", Condition = StiFilterCondition.LessThanOrEqualTo, DataType = StiFilterDataType.Numeric, Value1 = "0", Enabled = false });
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Post by Ivan »

Hello,

Let us know if you need any additional help.

Thank you.
Locked