Page 1 of 1

Access page subreport by name

Posted: Wed Sep 06, 2017 2:11 pm
by gabrielw3n
Hello.

I'm trying to make a report having two subreports, one on top and one at the bottom of the report page.

So, for example, I have a subReport_1 at the top and subReport_2 at the bottom, both having a text.

What I want is: based on a variable value, for example, 'var control', I can set this value to 1 or 2 and dismiss the subreport (set the enabled to false).

Well, in the report.mrt file I have the following part:

Code: Select all

"Pages": {
    "0": {
      "Ident": "StiPage",
      "Name": "Page1",
      "Guid": "9b0f01db5521b9448f152e93a5589f78",
      "Interaction": {
        "Ident": "StiInteraction",
        "SortingEnabled": false,
        "DrillDownEnabled": true
      },
      "Border": ";;2;;;;;solid:Black",
      "Brush": "solid:",
      "Components": {
        "0": {
          "Ident": "StiText",
          "Name": "Text5",
          "MinSize": "0,0",
          "MaxSize": "0,0",
          "ClientRectangle": "35.4,1.4,1.6,0.6",
          "Interaction": {
            "Ident": "StiInteraction"
          },
          "Text": {
            "Value": "{dsAmostrasGeradas.id}"
          },
          "Font": ";10;;",
          "Border": ";;;;;;;solid:Black",
          "Brush": "solid:",
          "TextBrush": "solid:Black"
        },
        "1": {
          "Ident": "StiText",
          "Name": "Text8",
          "MinSize": "0,0",
          "MaxSize": "0,0",
          "ClientRectangle": "32.6,1.4,2.8,0.6",
          "Interaction": {
            "Ident": "StiInteraction"
          },
          "Text": {
            "Value": "id"
          },
          "Font": ";10;;",
          "Border": ";;;;;;;solid:Black",
          "Brush": "solid:",
          "TextBrush": "solid:Black"
        },
        "2": {
          "Ident": "StiSubReport",
          "Name": "SubReport1",
          "MinSize": "0,0",
          "MaxSize": "0,0",
          "ClientRectangle": "0,0,20,12.8",
          "Interaction": {
            "Ident": "StiInteraction"
          },
          "Border": ";;;;;;;solid:Black",
          "Brush": "solid:",
          "SubReportPageGuid": "216812eb78964ac48b759d2c2663ec29"
        },
        "3": {
          "Ident": "StiText",
          "Name": "Text1",
          "MinSize": "0,0",
          "MaxSize": "0,0",
          "ClientRectangle": "9.2,4.8,1.8,0.6",
          "Interaction": {
            "Ident": "StiInteraction"
          },
          "Text": {
            "Value": "TEXT"
          },
          "Font": ";14;;",
          "Border": ";;;;;;;solid:Black",
          "Brush": "solid:",
          "TextBrush": "solid:Black",
          "Type": "Expression"
        },
        "4": {
          "Ident": "StiSubReport",
          "Name": "SubReport2",
          "MinSize": "0,0",
          "MaxSize": "0,0",
          "ClientRectangle": "0,13.4,20,15.4",
          "Interaction": {
            "Ident": "StiInteraction"
          },
          "Border": ";;;;;;;solid:Black",
          "Brush": "solid:",
          "SubReportPageGuid": "8e5825a446974a27949651b3a8e7a75f"
        },
        "5": {
          "Ident": "StiText",
          "Name": "Text2",
          "MinSize": "0,0",
          "MaxSize": "0,0",
          "ClientRectangle": "8.2,18.2,3,0.6",
          "Interaction": {
            "Ident": "StiInteraction"
          },
          "Text": {
            "Value": "TEXTO 2"
          },
          "Font": ";14;;",
          "Border": ";;;;;;;solid:Black",
          "Brush": "solid:",
          "TextBrush": "solid:Black",
          "Type": "Expression"
        }
      },
As we can see, I can theorically set the subReport_1 disabled, for example, like this:

Code: Select all

report.pages.list[0].components.list[4].enabled = false;
It doesn't work and I have no errors.

Is there a way to call some getByName method inside the pages so that I can do what I wish?

Thank you!

Re: Access page subreport by name

Posted: Thu Sep 07, 2017 6:40 pm
by HighAley
Hello.

The better way is to use the Conditions for this.
Uncheck the Component is Enabled option and when the expression is true the component will be hidden.

Thank you.