Page 1 of 1

Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Posted: Wed May 30, 2012 9:26 am
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?

Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Posted: Fri Jun 01, 2012 9:07 am
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.

Set Panel.Enabled via DataBand.BeforePrintEvent.Script

Posted: Fri Jun 29, 2012 3:33 pm
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.

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

Posted: Tue Jul 03, 2012 8:03 am
by MartinB
Can anyone please help with this?

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

Posted: Wed Jul 04, 2012 8:46 am
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.

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

Posted: Wed Jul 04, 2012 1:16 pm
by MartinB
Thanks Aleksey.

This worked:
objLabelArea.Conditions.Add(new StiCondition() { Column = "Students.BarcodeNumber", Condition = StiFilterCondition.LessThanOrEqualTo, DataType = StiFilterDataType.Numeric, Value1 = "0", Enabled = false });

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

Posted: Wed Jul 04, 2012 3:34 pm
by Ivan
Hello,

Let us know if you need any additional help.

Thank you.