Applying filters

You can apply filters to business views and data components such as tables, crosstabs and charts of a web report so as to narrow down the data displayed in the web report.

Applying filters to business views

When creating web reports, you can choose to apply some filter to the specified business view to narrow down the data scope of the data component using the business view.

In Web Report Studio, filters for business views are defined into two categories: predefined filters and user defined filters. As the name suggests, predefined filters are defined in advance when creating or editing the business views in JReport Designer, and user defined filters are created on business views while they are used.

Filters can be applied to a business view in the report wizard.

  1. In the report wizard, select the business view that you are going to add filters to from the Data Source drop-down list, and then click the Filter button on the right. The Query Filter dialog appears.
  2. The dialog has the basic and advanced modes for you to define a filter using either simple expressions or complex expressions.

    When it is in the advanced mode, you can also choose to apply a predefined filter of the specified business view from the Query Filter drop-down list. If you prefer to define a filter on your own, select User Defined from the drop-down list, and then define the filter according to your requirements. You can also edit a predefined filter if required and save it as a user defined filter to the business view.

  3. After you finish the report wizard, the specified filter is applied to the business view. If parameters are used in the filter conditions, they are listed in the Parameters panel and you can specify the parameter values in the panel to dynamically define the filter conditions.

Note: Query filters take effect on the component level, which means each time you create a component, you can apply a filter to the business view the component uses and it will not affect other components based on the same business view.

Filtering the data components in a report

There are the following ways you can take in order to filter the data components in a web report.

Using the Filter dialog

When using the Filter dialog to filter report data, you can only make the filter applied to a specific data component in the current web report.

To filter report data using the Filter dialog:

  1. Click Menu > Edit > Filter, or the Filter button on the Standard toolbar. The Filter dialog appears. See the dialog.
  2. From the Apply to drop-down list, select the component in the web report to which you want to apply the filter.

    Tip: For web reports created in JReport Designer, the default selected component and available components in the Apply to drop-down list are determined by the Default for Filter and Invisible for Filter Dialogs properties of the components in the web reports.

  3. Define the filter using either simple expressions or complex expressions.
  4. When done, click OK to apply the filter. If parameters are used in the filter conditions, they are listed in the Parameters panel and you can specify the parameter values in the panel to dynamically define the filter conditions.

The Filter dialog provides an entry to all the filters used in the current web report. You can click the Inspector button to view the detailed filter information in the Filter Inspector dialog.

Using filter controls

You can also use the Filter web control to filter one or more data components that use the same data source in a web report. A filter control can do filtering based on one field. For details, see Using filter control to filter report data.

Using the Filter panel

The Filter panel on the left of Web Report Studio is used to filter data components in the current report that are using the same business view. To do this:

  1. Add group and detail resources into the Filter panel by clicking + on the panel title bar. Each added group/detail and its values are housed in a separate box. Group and detail objects can be selected from the business views used by current report.
  2. Select the values you would like to filter the report data. The selected values applies a filter condition to all the data components in the current report that are using the same business view, regardless whether the data components contain the fields holding those values.

    You can make use of the Ctrl or Shift key to do multiple selection.

The value selection applies a filter condition and the logic is as follows:

The following shows more about working with the Filter panel:

You can use the buttons on the bottom of the Filter panel to deal with the value selection in the panel.

After right-clicking on a group/detail name title bar, these options are available for managing the group/detail object.

Notes:

Cascading relationship between filters

The Filter panel can be regarded as a collection of special filter controls which apply to all data components using the same data source. While common filter controls can choose the data components they apply, still under the circumstance of using the same data source.

When there are filter controls, including the special ones in the Filter panel, that apply to the same data components, and when these controls' fields have cascading relationship, the cascading relationship will be revealed when you select values in the controls.

For example, there is a filter control based on the field Country, a filter control on City, and another on State. The first two share one table while the third shares nothing with the other two. In this case, Country and City values will show cascading relationship, but State values will not participate. You select USA in the Country filter control, the values in the City filter control will change as follows if the control has scrollbar: the cities belong to USA are displayed in the upper area of the filter control, and the other cities are put in the lower area and grayed out. For the case that the City filter control has no scrollbar: all the values remain their positions and the values not belonging to USA are grayed out. In both cases all the values are selectable. But the State values remain as before, since the selection of them will not affect the data components that the Country and City filter controls control.

Using the shortcut menu

You can use filter-related commands on the shortcut menu to filter the data in a table. To do this, point to any value of the field other than the group by field, by which you want to filter data, then right-click to show the shortcut menu. You will see the Filter item which provides a submenu containing the following commands:

Using labels

For tables in web reports, you can use a label to control the filter conditions. This feature needs to be enabled at report design time.

  1. In JReport Designer, select a label in a table in a web report, and then set its Filterable property to true.
  2. Set the field by which you want to filter records as the value of the label's Bind Column property.
  3. Save the report and publish it to JReport Server.
  4. Run the report in Web Report Studio, and you can find that a filter button displayed beside the label. Click it to show the Filter list, which contains the same items as the Filter submenu. Click the corresponding item to filter the records.

    After a filter is applied on the field specified by the Bind Column property, the button will be highlighted. You can still click it to show the Filter list to change the filter condition or select the All item to remove the filter on the field.

Using server profile setting

You can also configure the server profile to enable filter records in tables by clicking the filter button on table column headers.

  1. Open the Profile > Customize Profile > Common tab.
  2. Check the option Filter on Column Headers to enable clicking the filter button on column headers to filter table records.
  3. Check Show Sort/Filter Status on Column Headers if you want the the filter button to be always displayed on the table column headers with the current filter status. If this option is unchecked, each time you want to get the filter button for a column, you need to put the mouse pointer on its header to make the button shown.
  4. Run a web report containing a table in Web Report Studio and you can click on the table column headers to filter data.

    To filter the table based on any column field, click on its column header to show the Filter list, which contains the same items as the Filter submenu. Click the corresponding item to filter the records.

    After a filter is applied on a field, the button on its column header will be highlighted. You can still click it to show the Filter list to change the filter condition or select the All item to remove the filter on the field.

Notes: