Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The trick is to render both controls and then turn one of the side’s controls off. This can be done by setting the e.Cancel property to true - this way the control instance will be removed from the report.

However, paging is only know known after every control has been laid out and page size has been taken into account (and grouping rules where data should be shown), so you will need to use the PrintOnPage event as controls wont know which page index its on until after PrintOnPage is done. The event will include the pageindex in the PrintOnPageEvent sent to the script method. Default the PageIndex is 0 based so first page is pageindex = 0 unless overridden.

...

  • Scripting is something that requires a developer and if overdone it will be quickly become hard to maintain - and it cant can't be supported by Perfion as it by definition is a custom code implementation.

    • This means that even simple scripted reports most likely will not be maintainable by end users.

  • Scripted reports should be considered sourcecode - thus its a good idea to have it in sourcecontrol systems like e.,g GIT. Can argue this would be a good practice for normal reports also.

  • It can be “debugged” in 2 ways - neither is supported by Perfion but can be useful.

    • SIMPLE
      Using simple output to System.Windows.Forms.MessageBox.Show - note that you will often end up showing a MessageBox for every time a control is rendered which can be a LOT of times for a report

    • ADVANCED (developer only and requires something like Visual studio)
      Script is runtime compiled C# - this means you can compile script code as a library and upload it to reports.

      image-20240429-134932.png

      Here you can supply the path to the compiled DLL.

      You will still need to have the method in the report for designer to be able to pick it up but instead of using script code you can just call your method in the DLL.
      so the script method

      Code Block
      private void turnOffIfEvenPage (object sender, DevExpress.XtraReports.UI.PrintOnPageEventArgs e) {
      // Images needs to be handled specially - otherwise they will reset to last image used.
          if (""+sender.GetType() == "Pims.Api.Reporting.PerfionImage" )
              ((Pims.Api.Reporting.PerfionImage)sender).ImageID = null;
          if( e.PageIndex %2  == 0){
              e.Cancel =true;     
          }    
      }

      becomes something like this

      Code Block
      private void turnOffIfEvenPage (object sender, DevExpress.XtraReports.UI.PrintOnPageEventArgs e) {
            if (MyNameSpace.ShouldITurnOffEvenPage(sender, e) ) [
              e.Cancel = true;
            }
       }

      The very cool thing here is that you attach a debugger to Perfion.exe and use breakpoints in your DLL project and you can inspect data structures (e.g., to see page index) . Note that any change to the code in a library / DLL project will require the report to be reloaded as it will only load the DLL on startup and then breakpoints will note fire as its not the same code..

...