Menu with Selectable Items
Some menu items can be added to groups to allow single or multiple item selection.
Z2UI5_CL_SMPC_APP_311
Controls
sap.ui.unified
UI5 1.127
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_311- Source file
z2ui5_cl_smpc_app_311.clas.abap↗- Library
- sap.ui.unified
- UI5 entity
sap.ui.unified.Menu- Demo kit sample
sap.ui.unified.sample.MenuSelectable- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.127
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: menu, sap.ui.unified, menuselectable, vbox, button, menuitem, menuitemgroup
Controls it builds
- sap.m.Button
- sap.m.VBox
- sap.ui.core.mvc.View
- sap.ui.unified.Menu
- sap.ui.unified.MenuItem
- sap.ui.unified.MenuItemGroup
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_311.clas.abap — 139 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords menu sap.ui.unified menuselectable vbox button menuitem menuitemgroup
" @summary Some menu items can be added to groups to allow single or multiple item selection.
CLASS z2ui5_cl_smpc_app_311 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_311 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_navigated( ).
view_display( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:u` v = `sap.ui.unified`
)->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMargin`
)->ele( `Button`
)->a( n = `id` v = `openMenu`
)->a( n = `text` v = `Open Menu`
" handlePressOpenMenu does menu.open( kbd, button, BeginTop, BeginBottom, button );
" the openBy dispatch falls back to exactly that call for a
" sap.ui.unified.Menu, anchored on the pressed button
)->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `theMenu` ) ( `openBy` ) ( `$event.oSource.sId` ) ) )
)->a( n = `ariaHasPopup` v = `Menu`
" the controller adds the loaded fragment with addDependent; the
" dependents aggregation is the declarative equivalent (app 060/227)
)->ele( `dependents`
)->ele( n = `Menu` ns = `u`
)->a( n = `id` v = `theMenu`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `New`
)->a( n = `icon` v = `sap-icon://create`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Open`
)->a( n = `icon` v = `sap-icon://open-folder`
)->ele( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Save`
)->a( n = `icon` v = `sap-icon://save`
)->ele( n = `submenu` ns = `u`
)->ele( n = `Menu` ns = `u`
" MenuItemGroup is a control @since 1.127 - kept 1:1 (POST_171)
)->ele( n = `MenuItemGroup` ns = `u`
)->a( n = `itemSelectionMode` v = `SingleSelect`
)->ele( n = `items` ns = `u`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Save locally`
)->a( n = `icon` v = `sap-icon://save`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Save to cloud`
)->a( n = `icon` v = `sap-icon://upload-to-cloud`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Save to memory`
)->a( n = `icon` v = `sap-icon://approvals`
)->end(
)->end(
)->end(
)->end(
)->end(
)->ele( n = `MenuItemGroup` ns = `u`
)->a( n = `itemSelectionMode` v = `MultiSelect`
)->ele( n = `items` ns = `u`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Bold`
)->a( n = `icon` v = `sap-icon://bold-text`
)->a( n = `selected` v = `true`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Italic`
)->a( n = `icon` v = `sap-icon://italic-text`
)->a( n = `selected` v = `true`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Underline`
)->a( n = `icon` v = `sap-icon://underline-text`
)->end(
)->end(
)->ele( n = `MenuItemGroup` ns = `u`
)->a( n = `itemSelectionMode` v = `SingleSelect`
)->ele( n = `items` ns = `u`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Left Alignment`
)->a( n = `icon` v = `sap-icon://text-align-left`
)->a( n = `selected` v = `true`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Center Alignment`
)->a( n = `icon` v = `sap-icon://text-align-center`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Right Alignment`
)->a( n = `icon` v = `sap-icon://text-align-right`
)->end(
)->end(
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Properties`
)->a( n = `icon` v = `sap-icon://action-settings`
)->tag( n = `MenuItem` ns = `u`
)->a( n = `text` v = `Exit`
)->a( n = `icon` v = `sap-icon://decline` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
ENDCLASS.
More in sap.ui.unified
- Menu Eventing — Menu with Menu Eventing
- Calendar with navigatable legend — An example of adding navigatable legend to the calendar.
- Complex — File Uploader Example with Parameters
- Color Picker Popover — Example of ColorPicker in a popover using the thin wrapper control sap.ui.unified.ColorPi…
- multiple months — Calendar with more than one month
- Date deselection with shortcut for today — An example of recommended implementation of deselection logic when the calendar is in sin…
- Single Interval Selection — Calendar where the user can select an interval or entire week (either by selecting its we…
- Multiple Day Selection — Calendar where the user can select multiple days, entire weeks (either by selecting its w…
- Special Days with Legend — Calendar with special days and legend
- Color Picker - displayMode: Default — Basic example of Color Picker. Note that you have to set the Color Picker mode to HSL to…
- Color Picker - displayMode: Large — Basic example of Color Picker. Note that you have to set the Color Picker mode to HSL to…
- Calendar with aria-haspopup on special day cells — Calendar demonstrating configurable aria-haspopup attribute on individual day cells via D…
On this page