Toolbar - Responsive
Toolbar items can be displayed depending on the current device.
Z2UI5_CL_SMPC_APP_163
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_163- Source file
z2ui5_cl_smpc_app_163.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.OverflowToolbar- Demo kit sample
sap.m.sample.ToolbarResponsive- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: overflowtoolbar, overflow, toolbar, sap.m, responsive, text, toolbarspacer, button, actionsheet
Controls it builds
- sap.m.ActionSheet
- sap.m.Button
- sap.m.Page
- sap.m.Text
- sap.m.Toolbar
- sap.m.ToolbarSpacer
- sap.ui.core.FragmentDefinition
- sap.ui.core.mvc.View
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_163.clas.abap — 169 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords overflowtoolbar overflow toolbar sap.m responsive text toolbarspacer button actionsheet
" @summary Toolbar items can be displayed depending on the current device.
CLASS z2ui5_cl_smpc_app_163 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
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_163 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( ).
" The original drives the overflow toolbar's button visibility from a
" separate 'range' media model ({range>/isNoPhone} ...). abap2UI5 has one
" default model, so those flags live flat in it and visible binds them
" directly (the 'range>' prefix is dropped - last path segment identical,
" which structural-diff matches).
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` v = `sap.m`
)->a( n = `height` v = `100%`
)->ele( `Page`
)->a( n = `showHeader` v = `false`
)->ele( `content`
)->tag( `Text`
)->a( n = `text` v = `See the actions in the footer toolbar.`
)->a( n = `class` v = `sapUiSmallMargin`
)->end(
)->ele( `footer`
)->ele( `Toolbar`
)->tag( `ToolbarSpacer`
)->tag( `Button`
)->a( n = `text` v = `Approve`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `type` v = `Accept`
)->tag( `Button`
)->a( n = `text` v = `Reject`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `type` v = `Reject`
)->tag( `Button`
)->a( n = `text` v = `Mark as Favorite`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} !== 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Send Email`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} !== 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Share`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} !== 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Print`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} !== 'Phone' && ${device>/media/range} !== 'Tablet' }`
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://print`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Tablet' }`
)->tag( `Button`
)->a( n = `text` v = `Export as Excel`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} !== 'Phone' && ${device>/media/range} !== 'Tablet' }`
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://overflow`
)->a( n = `press` v = client->_event( val = `OPEN_SHEET` arg = `$event.oSource.sId` )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Phone' || ${device>/media/range} === 'Tablet' }` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
IF client->get_event( ) = `OPEN_SHEET`.
" onOpen: Fragment.load( ActionSheet.fragment.xml ) + openBy( button ) -
" rebuilt 1:1 as a popover anchored to the pressed overflow button
DATA(sheet) = z2ui5_cl_ui5_view_builder=>factory( ).
sheet->ele( n = `FragmentDefinition` ns = `core`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->ele( `ActionSheet`
)->a( n = `title` v = `Menu`
)->a( n = `showCancelButton` v = `true`
)->a( n = `placement` v = `Top`
)->ele( `buttons`
)->tag( `Button`
)->a( n = `text` v = `Mark as Favorite`
)->a( n = `icon` v = `sap-icon://favorite`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Send Email`
)->a( n = `icon` v = `sap-icon://email`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Share`
)->a( n = `icon` v = `sap-icon://share-2`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Print`
)->a( n = `icon` v = `sap-icon://print`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Phone' }`
)->tag( `Button`
)->a( n = `text` v = `Export as Excel`
)->a( n = `icon` v = `sap-icon://excel-attachment`
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `{0}` ) ( `${$source>/text}` ) ) )
)->a( n = `visible` v = `{= ${device>/media/range} === 'Phone' || ${device>/media/range} === 'Tablet' }` ).
client->popover_display( xml = sheet->stringify( )
by_id = client->get_event_arg( ) ).
ENDIF.
ENDMETHOD.
METHOD model_init.
" the original's 'range' model - Device.media.getCurrentRange( 'Std' ) plus a
" live attachHandler on the same range set - has no ABAP counterpart and needs
" none: the framework publishes exactly that range as {device>/media/range},
" from the same 'Std' set and refreshed on every resize, so the six flags are
" expression bindings in the view. Seeding them here froze them at the desktop
" values until 2026-08-23, which left the overflow Button permanently hidden
" and the whole ActionSheet branch unreachable
ENDMETHOD.
ENDCLASS.
More in sap.m
- Check Box — Checkboxes allow users to select a subset of options. If you want to offer an off/on sett…
- Numeric Content of Different Colors — Shows NumericContent including numbers, units of measurement, and status arrows indicatin…
- Header Container - Vertical Mode — The Header Container with a vertical layout and with divider lines.
- Flex Box - Gap, Row Gap & Column Gap — You can add gap between rows and columns.
- Input - Types — Input type corresponds to the type attribute of the HTML input tag. On touch devices, it…
- Link — Here are some links. Typically links are used in user interfaces to trigger navigation to…
- Whitespaces Pattern — Renders whitespaces properly within controls
- Toolbar vs Bar vs OverflowToolbar — Toolbar handles overflow by shrinking items. OverflowToolbar provides an overflow menu. B…
- Flex Box - Render Type — Flex items can be rendered differently. By default, they are wrapped in a div element. Op…
- Object Attribute inside Table — This is an example of Object Attribute used inside Table.
- Combo box - Two columns layout — Use the combo box dropdown list with two columns layout if you need to display additional…
- List - Footer — With the 'footerText' property you can set a message that is shown at the very end of the…
On this page