Demystifying DevExpress XtraReport for Silverlight - Part 5

<< part 4 part 1 >>


This is the final part of what ideally should have been a three part write-up but has been split into a 5 part write-up. This part deals with the actual consumption or running of the report. To recap, to use DevExpress XtraReport control in Silverlight - one needs a web service broker - consumed by the client and which in return calls the appropriate report and streams back a valid XAML to the client which then displays it.

To consume or run the report from the client, one just needs a DocumentPreview Control which can be specified at design time or left till when needed at runtime. The thing to note when included at design time is to set the AutoCreateDocument to false to prevent the report from running automatically whenever the class it is included is instantiated. When invoking the reports, parameters values can be assigned. By default, the report is expected to pop-up a parameter dialog box when run for input. This action cam be suppressed by setting certain attributes of the Parameters collections in the designated report class. The two attributes that need to be toggled are :

  1. RequestParameters. This is a property found at the report level and needs to be set to false
  2. Visible. This is property of the individual parameter items and needs to be set to false as well




This is a sample code behind to invoke the report :

private void PreviewReport()
{

       ReportPreviewModel model = new 
                                         ReportPreviewModel(".././Reports/DevExpressReportingService.svc");
       model.ReportName = "CCA_Silverlight_600.Reports.SummaryReport";
       DocumentPreview1.Model = model;
       // set Default Parameter value on the client-side
       // Parameters are :
       //- id
       //- age
       //- Dept
       //- Supervisor
     model.Parameters["paramtId"].Value = MainVM..ID.ToString();
     model.Parameters["paramAge"].Value = MainVM..AgeString;
     model.Parameters["paramDept"].Value = DocVM..Dept;
     model.Parameters["paramSupervisor"].Value = DocVM..Supervisor;
     model.CreateDocument();
 }

Essentially, you will need to instantiate an instance of the ReportPreviewModel. You will need to specify the location of the service relative to the web or server project. If the service file is not located at the the topmost or root level, you will need a relative dot notation path specification. You will also need to specify the class name of the report to run with the namespace prefixed to it. All parameter values to be passed will also need to be specified against this instance. Finally, the instance of the ReportPreviewModel is hooked on to the DocumentPreview Control and then the CreateDocument method of the ReportPreviewModel is invoked to run the report.

One thing to note though, when the report is being rendered - it may not have been fully streamed back to the client and it may just be a partial rendition of the report. In situations like this - the "LAST page" navigation arrow button is disabled and you can actually monitor the progress of the report's generation from a progress bar at the bottom left of the DocimentPreview Control. All in all, this looks like a nice control to have - especially in a Silverlight setting. The major issue with it has always been the documentation which is all over the place.


<< part 4 part 1 >>

Comments

Popular posts from this blog

Decompiling Delphi - 3

Decompiling Delphi - 2

Artificial Intelligence, Oxymoron and Natural Intelligence