Fetch Unique & Sorted Parameter Values in Active Reports
ActiveReports is one of the most powerful report designers in the market. With its new PageLayout feature, it allows designing of reports at page level without using any banded sections. And therefore, it has become every developers’ first choice. ActiveReports offers various interactive features, which makes reporting easier and more interactive. One of those features would be the use of ActiveReports offers various interactive features, which makes reporting easier and more interactive. One of those features would be the use of parameters. The parameters are used to filer data that need to be shown at runtime of the report. The PageReport offers various parameter properties, extending its functionality and also making it more user-friendly.. The parameters are used to filer data that need to be shown at runtime of the report. The PageReport offers various parameter properties, extending its functionality and also making it more user-friendly. One of the most important parameters is the ‘MultiValue’ property. This allows you to display records in the reports on the basis of multiple parameters. However, when using a MultiValue Parameter, there might be certain scenarios when redundant-unsorted values are shown in the parameters dialog. This is the default behavior of the control and the duplicate values should be handled by the available values written for the parameter. In this blog we will discuss how we can fetch unique and sorted values in Parameters dialog. The workaround is quite simple. We need to create a new dataset for the parameter and write its query in a manner that unique and sorted data is fetched from the dataset. Eg : Select distinct Name_ From Table1 Order By Name_ Desc You may follow the below-mentioned steps :
- Create a new PageReport in the Active Reports designer
- Add a datasource and a dataset (DataSet1)
- Open the DataSet dialog for DataSet1 and set its query to :
- "Select distinct Name_ From Table1 Order By Name_ Desc 'query to fetch unique and sorted data"
- Add a new Parameter (ReportParameter1) and check its MultiValue property from Report-Parameters Dialog
- Under the Available Values tab, set the following properties for ReportParameter1 :
- Select the 'From Query' radio button
- DataSet : DataSet1
- Value Field : Name_
- Preview the Report. Observe that the rendered parameter list would have the unique and sorted values.
You may refer to the following image wherein two parameter lists are shown. One with redundant values while the other created using the above-mentioned steps, showing unique and sorted(in descending order) values. Refer to the attached rdlx file (along with the datasource) for complete implementation. Using this pagereport, the output will look like the following : Download Report File