Table
The table selection modes - none, single and multi - side by side, and what each returns.
Z2UI5_CL_SMP_APP_019
Learn
Table
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_019- Source file
z2ui5_cl_smp_app_019.clas.abap↗- Category
- Table
- Learning path
- Show many rows
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
- Documentation
- abap2ui5.github.io/docs/cookbook/model/tables ↗
Keywords: selectionmode, none, single, multi, segmentedbutton, checkbox
Controls it builds
- sap.m.Button
- sap.m.Column
- sap.m.ColumnListItem
- sap.m.MessageStrip
- sap.m.OverflowToolbar
- sap.m.Page
- sap.m.SegmentedButton
- sap.m.SegmentedButtonItem
- sap.m.Shell
- sap.m.Table
- sap.m.Text
- sap.m.Title
- 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_smp_app_019.clas.abap — 173 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords selectionmode none single multi segmentedbutton checkbox
" @summary The table selection modes - none, single and multi - side by side, and what each returns.
" @docs https://abap2ui5.github.io/docs/cookbook/model/tables
CLASS z2ui5_cl_smp_app_019 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_row,
selkz TYPE abap_bool,
title TYPE string,
value TYPE string,
descr TYPE string,
END OF ty_s_row.
TYPES ty_t_rows TYPE STANDARD TABLE OF ty_s_row WITH EMPTY KEY.
DATA t_tab TYPE ty_t_rows.
DATA t_tab_sel TYPE ty_t_rows.
DATA sel_mode TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_019 IMPLEMENTATION.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
)->ele( n = `View` ns = `mvc`
)->a( n = `displayBlock` v = `true`
)->a( n = `height` v = `100%`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:core` v = `sap.ui.core` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Table - Selection Modes: Single and Multi Select`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).
page->tag( `MessageStrip`
)->a( n = `text` v = `A SegmentedButton switches the table's selection mode (None, Single, Multi) at ` &&
`runtime; a second table below collects the rows selected in the first.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
page->ele( `SegmentedButton`
)->a( n = `selectedKey` v = client->_bind( sel_mode )
)->a( n = `selectionChange` v = client->_event( `BUTTON_SEGMENT_CHANGE` )
)->ele( `items`
)->tag( `SegmentedButtonItem`
)->a( n = `key` v = `None`
)->a( n = `text` v = `None`
)->tag( `SegmentedButtonItem`
)->a( n = `key` v = `SingleSelect`
)->a( n = `text` v = `SingleSelect`
)->tag( `SegmentedButtonItem`
)->a( n = `key` v = `SingleSelectLeft`
)->a( n = `text` v = `SingleSelectLeft`
)->tag( `SegmentedButtonItem`
)->a( n = `key` v = `SingleSelectMaster`
)->a( n = `text` v = `SingleSelectMaster`
)->tag( `SegmentedButtonItem`
)->a( n = `key` v = `MultiSelect`
)->a( n = `text` v = `MultiSelect` ).
page->ele( `Table`
)->a( n = `items` v = client->_bind( t_tab )
)->a( n = `headerText` v = `Table`
)->a( n = `mode` v = sel_mode
)->ele( `columns`
)->ele( `Column`
)->tag( `Text`
)->a( n = `text` v = `Title`
)->end(
)->ele( `Column`
)->tag( `Text`
)->a( n = `text` v = `Value`
)->end(
)->ele( `Column`
)->tag( `Text`
)->a( n = `text` v = `Description`
)->end(
)->end(
)->ele( `items`
)->ele( `ColumnListItem`
)->a( n = `selected` v = `{SELKZ}`
)->ele( `cells`
)->tag( `Text`
)->a( n = `text` v = `{TITLE}`
)->tag( `Text`
)->a( n = `text` v = `{VALUE}`
)->tag( `Text`
)->a( n = `text` v = `{DESCR}` ).
page->ele( `Table`
)->a( n = `items` v = client->_bind( t_tab_sel )
)->ele( `headerToolbar`
)->ele( `OverflowToolbar`
)->tag( `Title`
)->a( n = `text` v = `Selected Entries`
)->tag( `Button`
)->a( n = `press` v = client->_event( `BUTTON_READ_SEL` )
)->a( n = `text` v = `copy selected entries`
)->a( n = `icon` v = `sap-icon://pull-down`
)->end(
)->end(
)->ele( `columns`
)->ele( `Column`
)->tag( `Text`
)->a( n = `text` v = `Title`
)->end(
)->ele( `Column`
)->tag( `Text`
)->a( n = `text` v = `Value`
)->end(
)->ele( `Column`
)->tag( `Text`
)->a( n = `text` v = `Description`
)->end(
)->end(
)->ele( `items`
)->ele( `ColumnListItem`
)->ele( `cells`
)->tag( `Text`
)->a( n = `text` v = `{TITLE}`
)->tag( `Text`
)->a( n = `text` v = `{VALUE}`
)->tag( `Text`
)->a( n = `text` v = `{DESCR}` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
sel_mode = `None`.
t_tab = VALUE #( descr = `this is a description`
( title = `title_01` value = `value_01` )
( title = `title_02` value = `value_02` )
( title = `title_03` value = `value_03` )
( title = `title_04` value = `value_04` )
( title = `title_05` value = `value_05` ) ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( `BUTTON_SEGMENT_CHANGE` ).
client->message_toast_display( `Selection Mode changed` ).
ELSEIF client->check_on_event( `BUTTON_READ_SEL` ).
t_tab_sel = t_tab.
DELETE t_tab_sel WHERE selkz <> abap_true.
ENDIF.
view_display( ).
ENDMETHOD.
ENDCLASS.
More in Table
On this page