abap2UI5

Segmented Button in View Settings Dialog

Segmented Button used in View Settings Dialog component

Z2UI5_CL_SMPC_APP_516

Controls sap.m UI5 1.71

The facts

Repository
abap2UI5/samples-controls
Class
Z2UI5_CL_SMPC_APP_516
Source file
z2ui5_cl_smpc_app_516.clas.abap
Library
sap.m
UI5 entity
sap.m.SegmentedButton
Demo kit sample
sap.m.sample.SegmentedButtonVSD
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: segmentedbutton, segmented, button, sap.m, segmentedbuttonvsd, verticallayout, viewsettingsdialog, viewsettingsitem, viewsettingsfilteritem

Controls it builds

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_516.clas.abap — 168 lines Read it on GitHub ↗
" @keywords segmentedbutton segmented button sap.m segmentedbuttonvsd verticallayout viewsettingsdialog viewsettingsitem viewsettingsfilteritem
" @summary Segmented Button used in View Settings Dialog component
CLASS z2ui5_cl_smpc_app_516 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 popup_dialog_display.

  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smpc_app_516 IMPLEMENTATION.

  METHOD z2ui5_if_app~main.

    me->client = client.
    IF 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`     v = `sap.m`

        )->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`
                )->a( n = `press` v = client->_event( `DIALOG_OPEN` ) ).

    client->view_display( view->stringify( ) ).

  ENDMETHOD.


  METHOD on_event.

    CASE client->get_event( ).

      WHEN `DIALOG_OPEN`.
        popup_dialog_display( ).

      WHEN `CONFIRM`.
        " handleConfirm toasts the dialog's filterString when there is one
        DATA(filter_string) = client->get_event_arg( ).
        IF filter_string IS NOT INITIAL.
          client->message_toast_display( filter_string ).
        ENDIF.

    ENDCASE.

  ENDMETHOD.


  METHOD popup_dialog_display.

    DATA(popup) = z2ui5_cl_ui5_view_builder=>factory( ).

    popup->ele( n = `FragmentDefinition` ns = `core`
        )->a( n = `xmlns`      v = `sap.m`
        )->a( n = `xmlns:core` v = `sap.ui.core`

        )->ele( `ViewSettingsDialog`
            )->a( n = `id`      v = `mySettingsDialog`
            )->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` ).

    client->popup_display( popup->stringify( ) ).

  ENDMETHOD.

ENDCLASS.

More in sap.m

Search every abap2UI5 sample · the full list on one page

On this page