Grid Table
Keeps the active sap.ui.table column filters across a view model update, through the abap2UI5 uitableext custom control - without it they are reset.
Z2UI5_CL_SMP_APP_143
Learn
Grid Table
UI5 1.71
The facts
- Repository
- abap2UI5/samples
- Class
Z2UI5_CL_SMP_APP_143- Source file
z2ui5_cl_smp_app_143.clas.abap↗- Category
- Grid 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: column, filter, reset, refresh, uitableext, grid, alv
Controls it builds
- sap.f.DynamicPage
- sap.f.DynamicPageTitle
- sap.m.HBox
- sap.m.MessageStrip
- sap.m.Page
- sap.m.Shell
- sap.m.Text
- sap.m.Title
- sap.m.VBox
- sap.ui.core.mvc.View
- sap.ui.table.Column
- sap.ui.table.RowAction
- sap.ui.table.RowActionItem
- sap.ui.table.Table
- z2ui5.cc.UITableExt
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_143.clas.abap — 172 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords column filter reset refresh uitableext grid alv
" @summary Keeps the active sap.ui.table column filters across a view model update, through the abap2UI5 uitableext custom control - without it they are reset.
" @docs https://abap2ui5.github.io/docs/cookbook/model/tables
CLASS z2ui5_cl_smp_app_143 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_data,
field1 TYPE string,
field2 TYPE string,
field3 TYPE string,
END OF ty_s_data.
TYPES ty_t_data TYPE STANDARD TABLE OF ty_s_data WITH EMPTY KEY.
DATA gt_data TYPE ty_t_data.
METHODS on_init.
METHODS on_event.
METHODS view_display.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smp_app_143 IMPLEMENTATION.
METHOD on_event.
TRY.
IF client->check_on_event( `ROW_ACTION_ITEM_ADD` ).
client->message_toast_display( `Something` ).
ENDIF.
CATCH cx_root INTO DATA(x).
client->message_box_display( text = x->get_text( ) type = `error` ).
ENDTRY.
ENDMETHOD.
METHOD on_init.
gt_data = VALUE ty_t_data(
( field1 = `21` field2 = `T1` field3 = `TEXT1` )
( field1 = `22` field2 = `T1` field3 = `TEXT1` )
( field1 = `23` field2 = `T2` field3 = `TEXT1` )
( field1 = `24` field2 = `T2` field3 = `TEXT2` )
( field1 = `25` field2 = `T3` field3 = `TEXT2` ) ).
ENDMETHOD.
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`
)->a( n = `xmlns:f` v = `sap.f`
)->a( n = `xmlns:table` v = `sap.ui.table`
)->a( n = `xmlns:z2ui5` v = `z2ui5.cc` ).
DATA(page1) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `abap2UI5 - Grid Table - Keep Column Filters on Refresh`
)->a( n = `showNavButton` b = client->check_app_prev_stack( )
)->a( n = `navButtonPress` v = client->_event_nav_app_leave( )
)->a( n = `class` v = `sapUiContentPadding`
)->a( n = `id` v = `page_main` ).
page1->tag( `MessageStrip`
)->a( n = `text` v = `This sample uses the abap2UI5 uitableext custom control so the active sap.ui.table column ` &&
`filters are preserved across a view model update instead of being reset.`
)->a( n = `type` v = `Information`
)->a( n = `showIcon` b = abap_true
)->a( n = `class` v = `sapUiSmallMargin` ).
DATA(page) = page1->ele( n = `DynamicPage` ns = `f`
)->a( n = `headerExpanded` b = abap_true ).
page1->tag( n = `UITableExt` ns = `z2ui5`
)->a( n = `tableId` v = `Table1` ).
DATA(header_title) = page->ele( n = `title` ns = `f`
)->ele( n = `DynamicPageTitle` ns = `f` ).
header_title->ele( n = `heading` ns = `f`
)->ele( `HBox`
)->tag( `Title`
)->a( n = `text` v = `Table` ).
header_title->ele( n = `expandedContent` ns = `f` ).
header_title->ele( n = `snappedContent` ns = `f` ).
DATA(cont) = page->ele( n = `content` ns = `f` ).
DATA(table) = cont->ele( `VBox`
)->ele( n = `Table` ns = `table`
)->a( n = `rows` v = client->_bind( gt_data )
)->a( n = `alternateRowColors` b = abap_true
)->a( n = `enableCellFilter` b = abap_true
)->a( n = `fixedColumnCount` v = `1`
)->a( n = `rowActionCount` v = `1`
)->a( n = `selectionMode` v = `None`
)->a( n = `id` v = `Table1` ).
table->ele( n = `columns` ns = `table`
)->ele( n = `Column` ns = `table`
)->a( n = `sortProperty` v = `FIELD1`
)->a( n = `autoResizable` v = `true`
)->a( n = `filterProperty` v = `FIELD1`
)->tag( `Text`
)->a( n = `text` v = `Field1`
)->ele( n = `template` ns = `table`
)->tag( `Text`
)->a( n = `text` v = `{FIELD1}`
)->end(
)->end(
)->ele( n = `Column` ns = `table`
)->a( n = `sortProperty` v = `FIELD2`
)->a( n = `autoResizable` v = `true`
)->a( n = `filterProperty` v = `FIELD2`
)->tag( `Text`
)->a( n = `text` v = `Field2`
)->ele( n = `template` ns = `table`
)->tag( `Text`
)->a( n = `text` v = `{FIELD2}`
)->end(
)->end(
)->ele( n = `Column` ns = `table`
)->a( n = `sortProperty` v = `FIELD3`
)->a( n = `autoResizable` v = `true`
)->a( n = `filterProperty` v = `FIELD3`
)->tag( `Text`
)->a( n = `text` v = `Field3`
)->ele( n = `template` ns = `table`
)->tag( `Text`
)->a( n = `text` v = `{FIELD3}`
)->end(
)->end(
)->end(
)->ele( n = `rowActionTemplate` ns = `table`
)->ele( n = `RowAction` ns = `table`
)->ele( n = `RowActionItem` ns = `table`
)->a( n = `icon` v = `sap-icon://add`
)->a( n = `text` v = `Add`
)->a( n = `press` v = client->_event( val = `ROW_ACTION_ITEM_ADD` t_arg = VALUE #( ( `${MATNR}` ) ) ) ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
on_init( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ENDIF.
view_display( ).
on_event( ).
ENDMETHOD.
ENDCLASS.
More in Grid Table
- Grid Table — Events on Cell Level
- Grid Table — Full Example with sap.ui.table
On this page