Show TOC

Custom Fields in the Smart Filter BarLocate this document in the navigation structure

You can extend the filter bar using a custom filter field. To enable this, you must add a view extension and a corresponding controller extension, as in the following example:
Sample Code
"extends": {
			"extensions": {
		        "sap.ui.controllerExtensions": {
		          "sap.suite.ui.generic.template.ListReport.view.ListReport": {
		            "controllerName": "<myNamespace>.ext.controller.CustomFilter"
		          }
		        },
                "sap.ui.viewExtensions": { 
					"sap.suite.ui.generic.template.ListReport.view.ListReport": {
			            "SmartFilterBarControlConfigurationExtension|<myEntityset>": {
				              "className": "sap.ui.core.Fragment",
				              "fragmentName": "<myNamespace>.ext.fragment.CustomFilter",
				              "type": "XML"
				          },
You can add additional controls to the smart filter bar. The following methods are mandatory:
  • Using onBeforeRebindTable, you evaluate the settings in the custom fields and add the corresponding filters to the bindingParamters of the table.

  • Using getCustomAppStateData, you read the state of all custom fields and store that state in the object provided to enable the templates to use it for navigation.

  • Using restoreCustomAppStateData, you get the custom app state object you provided in getCustomAppStateData and set the corresponding values to your custom controls. For example, this method is called after returning from a navigation.

The method onInitSmartFilterBar is optional, to be used if a custom control must be bound to its own model, or if value changes must trigger an action.
The enhanced controller methods each call a corresponding extension method:
  • onBeforeRebindTableExtension

  • getCustomAppStateDataExtension

  • restoreCustomAppStateDataExtension

  • onInitSmartFilterBarExtension

Note The filterable fields are usually defined by metadata annotations. You only have to use the extension option at the SmartTemplate if the filter attribute can only be calculated on the client side.

For an example with step-by-step instructions, see Adding Filterable Field to the Smart Filter Bar.