Show TOC

Filtering in TablesLocate this document in the navigation structure

Use

The Web Dynpro table provides a user interface for filtering. The corresponding logic for filtering data must, however, be provided by the application itself.

Filtering in a Table is configurated differently depending on whether the application parameter WDUIGUIDLINE is set to GL11 or to GL20.

WDUIGUIDELINE=GL11

A Table or its columns can be filtered by the user if event Table.onFilter is bound. A filter line is then displayed below the bottom table column header line. Whether and how a table column can be filtered, depends on TableColumn.filterValue :

  • If TableColumn.filterValue is not bound, no filtering option is available for this column. The relevant cell in the filter column is inactive, as for example in the column Airline Currency in the example.

    Example

  • If TableColumn.filterValue is bound to an attribute with a value list or ABAP Dictionary fixed values, a DropDown list with these values will be rendered.

    Example

  • If TableColumn.filterValue is bound to an attribute without fixed values, an InputField will be rendered.

    Example

If you press the filter icon at the start of the filter line, or if you press ENTER in a filter InputField, the values of the filter line are put in the relevant attributes for TableColumn.filterValue, and event Table.onFilter is triggered. The actual filtering of the data must be done by the application itself. In simple cases, the application can use the method handler and the IF_WD_TABLE_METHOD_HNDL~APPLY_FILTERING() function available there.

Notes

  • If you use a DropDown list to filter a column, we recommend you always have an entry for resetting the filter. Either insert a "blank" entry (that is, value and key are blank strings) into the value list, or set the attribute to which the TableColumn.filterValue is bound to nullable, and initialize it with IF_WD_CONTEXT_ELEMENT~SET_ATTRIBUTE_NULL().

  • If you use an InputField to filter a column, we recommend you always use a text-based string ( String or C) for the attribute to which you have bound TableColumn.filterValue. This can be useful if the corresponding column contains figures, for example. Then you can enter, for example, wildcards ( *) and operators, such as > in the filter string. Note that IF_WD_TABLE_METHOD_HNDL~APPLY_FILTERING() can interpret filter strings like this.

  • If you nevertheless decide to use integers for TableColumn.filterValue rather than a text-based type, we recommend you set the attribute to nullable, and initialize it with IF_WD_CONTEXT_ELEMENT~SET_ATTRIBUTE_NULL(). This allows you to differentiate between the user not wanting to filter and the user wanting to filter after the initial value (for example, 0 in the case of integers).

  • The isFiltered property in the TableColumn can be used to indicate that a filter has been applied to a column.

WDUIGUIDELINE=GL20

If sorting or filtering has been applied to a column, you can click the header to open a menu in which you can configure the sort sequence or filter (see test component WDR_TEST_TABLE_BTC). This menu is loaded "on demand" from the server. It consists of the following menu options:

  • As described under Sorting in Tables, there may be two menu entries at the start that can be used for sorting.

  • If event Table.onFilter and TableColumn.filterValue are bound, the following menu options for filtering are added: (All) resets the filter, (Adjust…) opens a popup window, in which the user can enter a value, and then up to 100 filter suggestions are set. You have to distinguish between two cases for the filtering options in the menu:

    1. You want to use ABAP Dictionary fixed values or a value list for the filter suggestions.

      To do this you bind TableColumn.filterValue to an attribute with a value list or ABAP Dictionary fixed values. In addition, this attribute must either be nullable or the value list has a blank entry ( value and key are blank strings) that corresponds to resetting the filter. The following options are then rendered:

      • (All):

        When this option is selected, TableColumn.filterValue is either set to Null (if the corresponding attribute is nullable) or set to the initial value and the Table.OnFilter event is triggered. The application then has to reset the filter.

      • The values in the value list or ABAP Dictionary fixed values.

        When this entry is selected, TableColumn.filterValue is set to this value and the Table.onFilter event triggered.

      You can find a test example in the system in component WDR_TEST_TABLE_BTC, table column G/P Customer in the table at the bottom ( TableColumn with the name BOOK_TABLE_CUSTTYPE).

    2. You want to display a standard list of filter suggestions.

      To do this you bind TableColumn.filterValue to a context attribute whose type is preferably text-based. If you do not want to use a text-based type, set the attribute to nullable and initialize it accordingly. You also bind attribute TableColumn.filterValueSuggestions to an attribute of a context node with cardinality 0..n or 1..n, and fill this with filter suggestions. The following menu options will be rendered:

      • (All):

        Filter is reset. When this option is selected, TableColumn.filterValue is set to the initial value and also to Null (if the corresponding attribute is nullable) and/or the Table.OnFilter event is triggered.

      • (Adjust..):

        A special filter dialog is called. If event Table.onCustomFilter is bound, it is triggered. Otherwise Web Dynpro ABAP opens a popup in which a filter value can be entered.

      • Values from TableColumn.filterValueSuggestion.

        When this entry is selected, TableColumn.filterValue is set to this value and the Table.onFilter event triggered. If the number of entries exceeds a specific number (this can be determined using IF_WD_TABLE_METHOD_HNDL~GET_MAX_FILTER_SUGGESTIONS_CNT), instead of the FilterSuggestions an entry is added to the menu that indicates to the user that there are too many FilterSuggestions.

Comments

  • The isFiltered property in the TableColumn can be used to indicate that a filter has been applied to a column.

  • The Col event parameter of the onFilter event can also be used to easily determine the column in which a filter action has been selected from the table header menu.

  • Since this value is copied to TableColumn.filterValue when one of the filter suggestions is selected, TableColumn.filterValue and TableColumn.filterValueSuggestions must have the same type. This prevents problems from occurring during future conversions.

  • You can use supply functions to specify that the FilterSuggestions must be calculated when the menu is first opened. This immediately improves performance. In simple cases, method IF_WD_TABLE_METHOD_HNDL~SUPPLY_FILTER_SUGGESTIONS() can be used for this purpose.

  • If the Table data changes, you must also invalidate or repopulate the context node to which TableCOlumn.filterVLauesuggestions is bound.