Personalization for grid list
GridList using the personalization Engine
Z2UI5_CL_SMPC_APP_647
Controls
sap.m
UI5 1.97
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_647- Source file
z2ui5_cl_smpc_app_647.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.p13n.Engine- Demo kit sample
sap.m.sample.p13n.EngineGridList- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.97
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: engine, sap.m.p13n, p13n.enginegridlist, vbox, toolbar, title, toolbarseparator, toolbarspacer, button, gridlist, customlistitem, flexitemdata
Controls it builds
- sap.f.GridList
- sap.m.Button
- sap.m.CustomListItem
- sap.m.FlexItemData
- sap.m.HBox
- sap.m.Label
- sap.m.Title
- sap.m.Toolbar
- sap.m.ToolbarSeparator
- sap.m.ToolbarSpacer
- sap.m.VBox
- sap.m.p13n.Popup
- sap.m.p13n.SelectionPanel
- sap.ui.core.Icon
- 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_647.clas.abap — 272 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords engine sap.m.p13n p13n.enginegridlist vbox toolbar title toolbarseparator toolbarspacer button gridlist customlistitem flexitemdata
" @summary GridList using the personalization Engine
" @origin sap.m.sample.p13n.EngineGridList - https://sdk.openui5.org/entity/sap.m.p13n.Engine/sample/sap.m.sample.p13n.EngineGridList (status: generated - machine-written, not yet reviewed)
CLASS z2ui5_cl_smpc_app_647 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_item,
key TYPE string,
firstname TYPE string,
lastname TYPE string,
size TYPE string,
city TYPE string,
END OF ty_s_item.
TYPES ty_t_item TYPE STANDARD TABLE OF ty_s_item WITH EMPTY KEY.
DATA t_items TYPE ty_t_item.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
" every person the MetadataHelper knows, and the Items state (visible keys in order)
DATA t_persons TYPE ty_t_item.
DATA t_state TYPE string_table.
METHODS view_display.
METHODS set_p13n_data.
METHODS on_event.
METHODS handle_state_change.
METHODS p13n_names
IMPORTING
json TYPE string
RETURNING
VALUE(result) TYPE string_table.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_647 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` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:f` v = `sap.f`
)->a( n = `xmlns:core` v = `sap.ui.core`
)->a( n = `xmlns:p13n` v = `sap.m.p13n`
)->a( n = `xmlns:app` v = `http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1`
)->a( n = `height` v = `100%`
)->a( n = `class` v = `sapUiContentPadding`
)->ele( `VBox`
)->a( n = `class` v = `sapUiSmallMargin`
)->a( n = `width` v = `95%`
)->ele( `Toolbar`
)->a( n = `class` v = `sapUiSmallMarginBottom`
)->ele( `content`
)->tag( `Title`
)->a( n = `id` v = `title`
)->a( n = `text` v = `Persons`
)->tag( `ToolbarSeparator`
" the sap.ui.fl VariantManagement (p13nVm) is dropped - see the sidecar
)->tag( `ToolbarSpacer`
)->tag( `Button`
)->a( n = `icon` v = `sap-icon://action-settings`
)->a( n = `press` v = client->_event( `OPEN_PERSO` )
)->end(
)->end(
)->ele( n = `GridList` ns = `f`
)->a( n = `id` v = `persoList`
)->a( n = `items` v = client->_bind( t_items )
)->ele( n = `items` ns = `f`
)->ele( `CustomListItem`
)->a( n = `type` v = `Active`
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1`
)->a( n = `shrinkFactor` v = `0`
)->end(
)->ele( `HBox`
)->a( n = `justifyContent` v = `SpaceBetween`
)->ele( `VBox`
)->a( n = `justifyContent` v = `SpaceBetween`
)->a( n = `class` v = `sapUiSmallMarginTop sapUiSmallMarginBegin`
)->ele( `VBox`
)->a( n = `app:p13nKey` v = `firstName`
)->tag( `Title`
)->a( n = `text` v = `First Name`
)->tag( `Label`
)->a( n = `text` v = `{FIRSTNAME}`
)->end(
)->ele( `VBox`
)->a( n = `app:p13nKey` v = `lastName`
)->tag( `Title`
)->a( n = `text` v = `Last Name`
)->tag( `Label`
)->a( n = `text` v = `{LASTNAME}`
)->end(
)->ele( `VBox`
)->a( n = `app:p13nKey` v = `city`
)->tag( `Title`
)->a( n = `text` v = `City`
)->tag( `Label`
)->a( n = `text` v = `{CITY}`
)->end(
)->ele( `VBox`
)->a( n = `app:p13nKey` v = `size`
)->tag( `Title`
)->a( n = `text` v = `Size`
)->tag( `Label`
)->a( n = `text` v = `{SIZE}`
)->end(
)->end(
)->tag( n = `Icon` ns = `core`
)->a( n = `src` v = `sap-icon://customer`
)->a( n = `size` v = `2.5rem`
)->a( n = `class` v = `sapUiSmallMarginTop sapUiSmallMarginEnd sapUiSmallMarginBottom`
)->end(
)->end(
)->end(
" the popup Engine.show( ) creates for the Items SelectionController
)->ele( n = `dependents` ns = `f`
)->ele( n = `Popup` ns = `p13n`
)->a( n = `id` v = `p13nPopup`
)->a( n = `close` v = client->_event(
val = `P13N_CLOSE`
t_arg = VALUE #( ( `${$parameters>/reason}` )
( `$event.oSource.getPanels()[0].getP13nData(true)` ) ) )
)->ele( n = `panels` ns = `p13n`
)->tag( n = `SelectionPanel` ns = `p13n`
)->a( n = `id` v = `itemsPanel`
)->a( n = `showHeader` v = `true`
)->a( n = `enableCount` v = `true` ).
client->view_display( view->stringify( ) ).
" a rebuilt view carries a fresh, empty panel
set_p13n_data( ).
ENDMETHOD.
METHOD set_p13n_data.
" the SelectionController's panel data: the visible persons in state order,
" then the hidden ones sorted by label
DATA(json) = ``.
LOOP AT t_state INTO DATA(key).
DATA(person) = t_persons[ key = key ].
json = |{ json },\{"name":"{ key }","label":"{ person-firstname } { person-lastname }","visible":true\}|.
ENDLOOP.
DATA(hidden) = t_persons.
LOOP AT hidden INTO person.
IF line_exists( t_state[ table_line = person-key ] ).
DELETE hidden WHERE key = person-key.
ENDIF.
ENDLOOP.
SORT hidden BY firstname lastname.
LOOP AT hidden INTO person.
json = |{ json },\{"name":"{ person-key }","label":"{ person-firstname } { person-lastname }","visible":false\}|.
ENDLOOP.
json = |[{ shift_left( val = json sub = `,` ) }]|.
client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `itemsPanel` ) ( `setP13nData` ) ( json ) ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `OPEN_PERSO`.
" Engine.show( ): the panel shows the current state, a cancelled edit is gone
set_p13n_data( ).
client->follow_up_action( val = client->cs_event-control_by_id
t_arg = VALUE #( ( `p13nPopup` ) ( `open` ) ) ).
WHEN `P13N_CLOSE`.
" the Engine applies the panel state on Ok only
IF client->get_event_arg( ) = `Ok`.
t_state = p13n_names( client->get_event_arg( 2 ) ).
handle_state_change( ).
ENDIF.
ENDCASE.
ENDMETHOD.
METHOD handle_state_change.
" like handleStateChange: the items become the visible persons, in state order
t_items = VALUE #( FOR key IN t_state ( t_persons[ key = key ] ) ).
ENDMETHOD.
METHOD p13n_names.
" getP13nData( true ) arrives as a JSON array of the panel's flat item
" objects; collect their names in order
SPLIT json AT `}` INTO TABLE DATA(objects).
LOOP AT objects INTO DATA(object).
DATA(offset) = find( val = object sub = `"name":"` ).
IF offset >= 0.
INSERT substring_before( val = substring( val = object off = offset + 8 ) sub = `"` ) INTO TABLE result.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD model_init.
t_persons = VALUE #(
( key = `person1` firstname = `Peter` lastname = `Mueller` size = `1.75` city = `Walldorf` )
( key = `person2` firstname = `Petra` lastname = `Maier` size = `1.85` city = `Walldorf` )
( key = `person3` firstname = `Thomas` lastname = `Smith` size = `1.95` city = `Walldorf` )
( key = `person4` firstname = `Maria` lastname = `Jones` size = `1.55` city = `Walldorf` )
( key = `person5` firstname = `John` lastname = `Williams` size = `1.65` city = `Walldorf` ) ).
t_items = t_persons.
t_state = VALUE #( FOR person IN t_persons ( person-key ) ).
ENDMETHOD.
ENDCLASS.
More in sap.m
- Dynamic Date Range - Open by Another Control — This example shows Dynamic Date Range which is opened by another control.
- Dynamic Date Range with Custom Options — This example shows the Dynamic Date Range control with custom options for interval or dat…
- Expandable Text — The ExpandableText control can be used to display a larger texts inside a table, list or…
- p13n.Container usage in a Dialog/Popover — Dialog & Popover with a sap.m.P13nContainer as content.
- Personalization for responsive table — Responsive Table using the personalization Engine
- Personalization implementing custom filter controls — Filtering using the personalization Engine
- Personalization for grid table — Grid Table using the personalization Engine
- Personalization with multiple SelectionControllers — Personalization for Reponsive Table using multiple SelectionControllers
- p13n.Popup usage — Dialog with sap.m.p13n/* Panels
- VariantManagement using dedicated items — VariantManagement with dedicated items
- Plugin for Responsive Table (sap.m.Table) - File Name validation configuration — This example demonstrates the usage of fileNameValidationConfig property to configure fil…
- Plugin for Responsive Table (sap.m.Table) - File Preview with Custom Page Content for non supported file types — This example showcases how to display custom page content for non supported file types in…
On this page