8th May 2015

DevExpress XtraReports – Filtering Report Via Script

DevExpress XtraReports – Filtering Report Via Script

Scenario

Usually when creating XtraReports via the XtraReports designer at runtime the standard Filter String functionality within the report properties is sufficient to filter the report and give the data required, however the Filter String functionality within the designer is limited and for some scenarios it has been necessary for us to the leave the Filter String blank and filter the XtraReport via a script.

We usually need to implement this functionally when a report parameter belongs to a different session which means we cannot directly filter on objects when they are in different sessions so we must filter them on their OID which cannot be done using the standard Filter String within the designer, it may also be necessary to use this functionality when you wish to get data from other fields stored against your parameters not just the OID.

Solution

The first step is to ensure that the current Filter String within the XtraReport properties is blank to avoid any unplanned data filtering. Next open up the Property Grid for the XtraReport, find and expand the ‘Scripts’ group, from the group click the drop down against the Parameters Submitted field and from the list click on New.


This will create a blank ParametersRequestSubmit event script within the script editor of your report, switch to the scripts view to see this event. 

Next within the event define your custom filter string, the code below shows how to access the report parameters within the script and how to set your custom filter string as the reports filter.



Now when you submit the parameters of the report the filter will be activated and filter the report accordingly.

Fill in this quick form and discover your digital future
Choose your interests:

Where to find us

We'd love to welcome you into our office! We're only 20 miles north of Peterborough, conveniently just off the A16.

Carver House
Apex Court, Elsoms Way
Pinchbeck
Lincolnshire
PE11 3UL