Improved Parameter Support for Reports

DevExpress Data Blog
03 August 2012

There were a number of gems recently added to our already fabulous reporting suite. One of the interesting ones was improved parameter support. Previously one could only create and expose parameters over integral types. A great example is filtering a report by a CategoryId. Before you would only be able to create a parameter of type int and have users type in numbers rather than category names. With our improved parameters dialog there are now additional options to choose from:

New Report Parameter Dialog

Once you check the “Supports the collection of standard values” checkbox you now have the ability to create a set of values that the parameter can take. These can be created either by a collection of static values or binding to a set of dynamic values.

Static Values

This option simply lets you define the set of available options manually.

Static Values in Report Parameter Dialog

The interface allows for the entry of the actual value passed as the parameter along with a description of what will be displayed.

Dynamic Values

Using dynamic values allows for binding to a set of key/value pairs to be displayed.

Dynamic Values in Report Parameter Dialog

In this case we need to set the source of the data, how the data is retrieved, as well as the value and display members. At runtime both methodologies yield the following result:

Report Parameter Values in Report Preview

Now your users can choose from an intelligible list of options that are better suited to your user while dealing with the pieces of data (like an id number) your system likes in the background.

Wait, there’s more

The next question I will invariably get is this:

“But Seth, our reports are not bound to datasets with table adapters! Can I still have dynamic parameters?”

Of course! In this particular case the best course of action is to use a Static Values list. When doing the intial setup you can place any value to start. We can then take advantage of the ParametersRequestBeforeShow event to populate the static value list as we see fit:

private void ProductReport_ParametersRequestBeforeShow(object sender, ParametersRequestEventArgs e)
    if (CategoryId.LookUpSettings is StaticListLookUpSettings)
        var lookup = (StaticListLookUpSettings)CategoryId.LookUpSettings;
            new LookUpValue { Value = 1, Description = "AAA" }

            new LookUpValue { Value = 2, Description = "BBB" }

            new LookUpValue { Value = 3, Description = "CCC" }

This code is deliberately simple to show the possibilities. Here I am simply hand coding the available parameter options directly into the method. One could imagine a scenario where we make a service/database/foo call to retrieve the key/value pairs to subsequently populate the list. Running the previous code will result in the following:

Report Parameter Custom Values in Report Preview

This new addition to our reporting suite will definitely simplify our ability to help our end users consume dynamic reports.

As always, if there are any comments and/or questions, feel free to get a hold of me!

Seth Juarez
Twitter: @SethJuarez

Want The Best Reporting Tool Ever?

Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now:

Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

Follow SethJuarez on Twitter

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.