Filtering Multiple Systems
2 minute read
If the user is supposed to select multiple values, it is best to define a checked list box for this purpose.
To create this dialog, first define a new data source. This data source can then be used to supply the selection list values. Make sure to indicate in the data source how to sort the list because the components will output the values as they appear in the table without considering the alphabetical sort order.
First, create a new form in the Report Designer by right-clicking the horizontal area to the right of the Preview tab and selecting New Form from the context menu.
Use the toolbox to add a label as the first element and enter System: for the Text property.
Now, add a checked list box to enable the selection of multiple systems. For the list box, specify FormHosts.HostName as the data source under the (Data Bindings - Items) property. In the (Name) property of the list box, assign the name cbxSystems. Then, add two buttons. For one of the buttons, select Cancel as the Dialog Result property, and for the other one, select OK as the Dialog Result property. Change the Text properties to OK and Cancel, respectively. This completes the dialog creation.
Next, change to the ReportPage tab to add the data output components. Define a data band and select the tHosts table as its data source. For the table, set the Connect On Start property to True. Then, add a text box to the data band and enter tHosts.HostName as the Text property.
Next, double-click the data band to open the Data Setup dialog. There, go to the Filters page to add a filter and enter the following expression: cbxSystems.Control.checkedItems.contains(tHosts.HostName). This way, only systems will be output whose name matches the name of one of the selected systems. This statement compares each of the selected systems with tHosts.HostName and if it contains the name of the system, the system will be displayed.
The expression is composed of cbxSystems (the name of the list box), Control to access the control, CheckedItems (the list of the selected systems), Contains (a comparison function), and (tHosts.HostName) which references the names of the systems in the tHosts table.
Only the selected values will be included in the report.