View Settings Dialog - Custom Tabs
You can have custom tabs with your own defined content in the View Settings Dialog, as shown in this example.
Z2UI5_CL_SMPC_APP_297
Controls
sap.m
UI5 1.132
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_297- Source file
z2ui5_cl_smpc_app_297.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.ViewSettingsDialog- Demo kit sample
sap.m.sample.ViewSettingsDialogCustomTabs- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.132
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: viewsettingsdialog, settings, dialog, sap.m, viewsettingsdialogcustomtabs, html, viewsettingsitem, viewsettingsfilteritem, viewsettingscustomtab, panel, label, segmentedbutton
Controls it builds
- sap.m.Button
- sap.m.DatePicker
- sap.m.Label
- sap.m.Panel
- sap.m.SegmentedButton
- sap.m.SegmentedButtonItem
- sap.m.ViewSettingsCustomTab
- sap.m.ViewSettingsDialog
- sap.m.ViewSettingsFilterItem
- sap.m.ViewSettingsItem
- sap.ui.core.HTML
- sap.ui.core.mvc.View
- sap.ui.layout.VerticalLayout
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
Run it here
The sample running, in this page — the app on its own, with no editor over it.
Switch to Playground with this code
Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.
The ABAP
z2ui5_cl_smpc_app_297.clas.abap — 421 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords viewsettingsdialog settings dialog sap.m viewsettingsdialogcustomtabs html viewsettingsitem viewsettingsfilteritem viewsettingscustomtab panel label segmentedbutton
" @summary You can have custom tabs with your own defined content in the View Settings Dialog, as shown in this example.
CLASS z2ui5_cl_smpc_app_297 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA date_value_state TYPE string.
DATA date_value_state_text TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
METHODS on_event.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_297 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
model_init( ).
view_display( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:l` v = `sap.ui.layout`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns` v = `sap.m`
" the sample's own style.css - the view carries vsdSetting and vsd-dp
" and the rules behind them have to come with it (apps 122/124/133).
" \{ \} escaped: the XMLView parser reads an unescaped brace as a binding
)->tag( n = `HTML` ns = `core`
)->a( n = `content` v = `<style>.sapMSegB.vsdSetting\{margin-bottom:1rem\}` &&
`.vsd-dp\{margin-inline-start:2rem;margin-block-start:2rem\}</style>`
" the three controller-loaded fragments, declared in the view's dependents aggregation
)->ele( n = `dependents` ns = `mvc`
)->ele( `ViewSettingsDialog`
)->a( n = `id` v = `settingsDialog`
)->a( n = `confirm` v = client->_event( val = `CONFIRM` arg = `${$parameters>/filterString}` )
)->ele( `sortItems`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Field 1`
)->a( n = `key` v = `1`
)->a( n = `selected` v = `true`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Field 2`
)->a( n = `key` v = `2`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Field 3`
)->a( n = `key` v = `3`
)->end(
)->ele( `groupItems`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Field 1`
)->a( n = `key` v = `1`
)->a( n = `selected` v = `true`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Field 2`
)->a( n = `key` v = `2`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Field 3`
)->a( n = `key` v = `3`
)->end(
)->ele( `filterItems`
)->ele( `ViewSettingsFilterItem`
)->a( n = `text` v = `Field1`
)->a( n = `key` v = `1`
)->ele( `items`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value A`
)->a( n = `key` v = `1a`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value B`
)->a( n = `key` v = `1b`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value C`
)->a( n = `key` v = `1c`
)->end(
)->end(
)->ele( `ViewSettingsFilterItem`
)->a( n = `text` v = `Field2`
)->a( n = `key` v = `2`
)->ele( `items`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value A`
)->a( n = `key` v = `2a`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value B`
)->a( n = `key` v = `2b`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value C`
)->a( n = `key` v = `2c`
)->end(
)->end(
)->ele( `ViewSettingsFilterItem`
)->a( n = `text` v = `Field3`
)->a( n = `key` v = `3`
)->ele( `items`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value A`
)->a( n = `key` v = `3a`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value B`
)->a( n = `key` v = `3b`
)->tag( `ViewSettingsItem`
)->a( n = `text` v = `Value C`
)->a( n = `key` v = `3c`
)->end(
)->end(
)->end(
)->ele( `customTabs`
)->ele( `ViewSettingsCustomTab`
)->a( n = `id` v = `app-settings`
)->a( n = `icon` v = `sap-icon://action-settings`
)->a( n = `title` v = `Settings`
)->a( n = `tooltip` v = `Application Settings`
)->ele( `content`
)->ele( `Panel`
)->a( n = `height` v = `338px`
)->ele( `content`
)->tag( `Label`
)->a( n = `text` v = `Theme`
)->a( n = `design` v = `Bold`
)->a( n = `id` v = `VSDThemeLabel`
)->ele( `SegmentedButton`
)->a( n = `class` v = `vsdSetting`
)->a( n = `selectedItem` v = `VSDsap_quartzlight`
)->a( n = `id` v = `VSDThemeButtons`
)->a( n = `width` v = `100%`
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `High Contrast Black`
)->a( n = `id` v = `VSDsap_hcb`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `Quartz Light`
)->a( n = `id` v = `VSDsap_quartzlight`
)->end(
)->end(
)->tag( `Label`
)->a( n = `text` v = `Compact Content Density`
)->a( n = `design` v = `Bold`
)->ele( `SegmentedButton`
)->a( n = `class` v = `vsdSetting`
)->a( n = `selectedItem` v = `VSDcompactOn`
)->a( n = `id` v = `VSDCompactModeButtons`
)->a( n = `width` v = `100%`
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `On`
)->a( n = `id` v = `VSDcompactOn`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `Off`
)->a( n = `id` v = `VSDcompactOff`
)->end(
)->end(
)->tag( `Label`
)->a( n = `text` v = `Right To Left Mode`
)->a( n = `design` v = `Bold`
)->ele( `SegmentedButton`
)->a( n = `selectedItem` v = `VSDRTLOff`
)->a( n = `id` v = `VSDRTLButtons`
)->a( n = `width` v = `100%`
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `On`
)->a( n = `id` v = `VSDRTLOn`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `Off`
)->a( n = `id` v = `VSDRTLOff`
)->end(
)->end(
)->end(
)->end(
)->end(
)->end(
)->ele( `ViewSettingsCustomTab`
)->a( n = `id` v = `example-settings`
)->a( n = `tooltip` v = `default icon`
)->ele( `content`
)->tag( `Button`
)->a( n = `text` v = `simple button example`
)->end(
)->end(
)->end(
)->end(
)->ele( `ViewSettingsDialog`
)->a( n = `id` v = `settingsDialogCustomTab`
)->a( n = `confirm` v = client->_event( val = `CONFIRM` arg = `${$parameters>/filterString}` )
)->ele( `customTabs`
)->ele( `ViewSettingsCustomTab`
)->a( n = `id` v = `app-settings-single`
)->a( n = `icon` v = `sap-icon://action-settings`
)->a( n = `title` v = `Settings`
)->a( n = `tooltip` v = `Application Settings`
)->ele( `content`
)->ele( `Panel`
)->a( n = `height` v = `386px`
)->tag( `Label`
)->a( n = `text` v = `Theme`
)->a( n = `design` v = `Bold`
)->a( n = `id` v = `VSDThemeLabelSingle`
)->ele( `SegmentedButton`
)->a( n = `class` v = `vsdSetting`
)->a( n = `selectedItem` v = `VSDsap_quartzlightSingle`
)->a( n = `id` v = `VSDThemeButtonsSingle`
)->a( n = `width` v = `100%`
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `High Contrast Black`
)->a( n = `id` v = `VSDsap_hcbSingle`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `Quartz Light`
)->a( n = `id` v = `VSDsap_quartzlightSingle`
)->end(
)->end(
)->tag( `Label`
)->a( n = `text` v = `Compact Content Density`
)->a( n = `design` v = `Bold`
)->ele( `SegmentedButton`
)->a( n = `class` v = `vsdSetting`
)->a( n = `selectedItem` v = `VSDcompactOnSingle`
)->a( n = `id` v = `VSDCompactModeButtonsSingle`
)->a( n = `width` v = `100%`
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `On`
)->a( n = `id` v = `VSDcompactOnSingle`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `Off`
)->a( n = `id` v = `VSDcompactOffSingle`
)->end(
)->end(
)->tag( `Label`
)->a( n = `text` v = `Right To Left Mode`
)->a( n = `design` v = `Bold`
)->ele( `SegmentedButton`
)->a( n = `selectedItem` v = `VSDRTLOffSingle`
)->a( n = `id` v = `VSDRTLButtonsSingle`
)->a( n = `width` v = `100%`
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `On`
)->a( n = `id` v = `VSDRTLOnSingle`
)->tag( `SegmentedButtonItem`
)->a( n = `text` v = `Off`
)->a( n = `id` v = `VSDRTLOffSingle`
)->end(
)->end(
)->end(
)->end(
)->end(
)->end(
)->end(
)->ele( `ViewSettingsDialog`
)->a( n = `id` v = `settingsDialogDatePicker`
)->a( n = `confirm` v = client->_event( val = `CONFIRM` arg = `${$parameters>/filterString}` )
)->a( n = `beforeClose` v = client->_event(
val = `BEFORE_CLOSE`
" _bind( ) - NOT path = abap_true: an ABAP template eats the
" braces (|${ ... }| yields "$" + the bare path), and $/PATH is
" not a token the UI5 event-handler parser knows. The braced
" form gives the ${/PATH} the expression needs
s_ctrl = VALUE #( prevent_default_expr =
|${ client->_bind( date_value_state ) } === 'Error'| ) )
)->ele( `customTabs`
)->ele( `ViewSettingsCustomTab`
)->a( n = `id` v = `app-settings-datepicker`
)->a( n = `icon` v = `sap-icon://action-settings`
)->a( n = `title` v = `Settings`
)->a( n = `tooltip` v = `Application Settings`
)->ele( `content`
)->tag( `DatePicker`
)->a( n = `id` v = `datePicker`
)->a( n = `class` v = `vsd-dp`
)->a( n = `width` v = `80%`
)->a( n = `valueState` v = client->_bind( date_value_state )
)->a( n = `valueStateText` v = client->_bind( date_value_state_text )
)->a( n = `change` v = client->_event( val = `DATE_CHANGE` arg = `${$parameters>/valid}` )
)->end(
)->end(
)->end(
)->end(
)->end(
)->ele( n = `VerticalLayout` ns = `l`
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `width` v = `100%`
)->tag( `Button`
)->a( n = `text` v = `Open View Settings Dialog with several tabs`
)->a( n = `press` v = client->_event( `OPEN_DIALOG` )
)->tag( `Button`
)->a( n = `text` v = `Open View Settings Dialog with single custom tab`
)->a( n = `press` v = client->_event( `OPEN_SINGLE_TAB` )
)->tag( `Button`
)->a( n = `text` v = `Open View Settings Dialog with single custom tab with DatePicker`
)->a( n = `press` v = client->_event( `OPEN_DATE_PICKER` ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `OPEN_DIALOG`.
client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `settingsDialog` ) ( `open` ) ) ).
WHEN `OPEN_SINGLE_TAB`.
client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `settingsDialogCustomTab` ) ( `open` ) ) ).
WHEN `OPEN_DATE_PICKER`.
client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `settingsDialogDatePicker` ) ( `open` ) ) ).
WHEN `DATE_CHANGE`.
" the original validateDate: an unparsable date marks the field
IF client->get_event_arg( ) = abap_true.
date_value_state = `None`.
date_value_state_text = ``.
ELSE.
date_value_state = `Error`.
date_value_state_text = `Invalid date. Please enter a date in the correct format.`.
ENDIF.
WHEN `BEFORE_CLOSE`.
" the client already vetoed the close when the state is Error (see the
" prevent_default_expr on the wire); the backend only adds the message
IF date_value_state = `Error`.
client->message_toast_display( `The entered date is invalid. Please correct it before closing the dialog.` ).
ENDIF.
WHEN `CONFIRM`.
DATA(filter_string) = client->get_event_arg( ).
IF filter_string IS NOT INITIAL.
client->message_toast_display( filter_string ).
ENDIF.
ENDCASE.
ENDMETHOD.
METHOD model_init.
date_value_state = `None`.
ENDMETHOD.
ENDCLASS.
More in sap.m
- MultiInput with Value Help — MultiInput that includes a SelectDialog as a value help dialog
- Notification List Group with data bindings — A control suitable for grouping notifications. The sample uses JSON data bindings.
- Panel - Background Design — Panels support different background designs for better visual distinction inside containe…
- Message View with Grouping — A sample with Message View and inside a Dialog and grouping of items
- View Settings Dialog - Custom Filters — You can have custom filters in your View Settings Dialog, as shown in this example here.
- View Settings Dialog - Custom Search — You can filter the items in the filter details page using different string filter operato…
- Table - View Settings & Menus — The View Settings Dialog is standard UI pattern for specifying sorting, grouping and filt…
- Input - Description — This sample illustrates the usage of the description with input fields, e.g. description…
- Input - Password — To make sure the password is not shown as clear text you set the 'type' of an input contr…
- Input - Suggestions wrapping — Suggestions wrap automatically when longer then the dropdown width
- TextArea - Growing — Since 1.38 the growing property of sap.m.TextArea gives the ability of a control to autom…
- TextArea - Value States — This sample illustrates the different value states of the sap.m.TextArea control.
On this page