|
| 1 | +class Z2UI5_CL_DEMO_APP_183 definition |
| 2 | + public |
| 3 | + create public . |
| 4 | + |
| 5 | +public section. |
| 6 | + |
| 7 | + interfaces IF_SERIALIZABLE_OBJECT . |
| 8 | + interfaces Z2UI5_IF_APP . |
| 9 | + |
| 10 | + types: |
| 11 | + BEGIN OF ty_row, |
| 12 | + count TYPE i, |
| 13 | + value TYPE string, |
| 14 | + descr TYPE string, |
| 15 | + icon TYPE string, |
| 16 | + info TYPE string, |
| 17 | + checkbox TYPE abap_bool, |
| 18 | + percentage(5) TYPE p DECIMALS 2, |
| 19 | + valuecolor TYPE string, |
| 20 | + END OF ty_row . |
| 21 | + |
| 22 | + data: |
| 23 | + t_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY . |
| 24 | + data CHECK_INITIALIZED type ABAP_BOOL . |
| 25 | + data CHECK_UI5 type ABAP_BOOL . |
| 26 | + data MV_KEY type STRING . |
| 27 | + |
| 28 | + methods REFRESH_DATA . |
| 29 | + PROTECTED SECTION. |
| 30 | + PRIVATE SECTION. |
| 31 | +ENDCLASS. |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +CLASS Z2UI5_CL_DEMO_APP_183 IMPLEMENTATION. |
| 36 | + |
| 37 | + |
| 38 | + METHOD REFRESH_DATA. |
| 39 | + |
| 40 | + DO 100 TIMES. |
| 41 | + DATA ls_row TYPE ty_row. |
| 42 | + ls_row-count = sy-index. |
| 43 | + ls_row-value = 'red'. |
| 44 | +* info = COND #( WHEN sy-index < 50 THEN 'completed' ELSE 'uncompleted' ) |
| 45 | + ls_row-descr = 'this is a description'. |
| 46 | + ls_row-checkbox = abap_true. |
| 47 | +* percentage = COND #( WHEN sy-index <= 100 THEN sy-index ELSE '100' ) |
| 48 | + ls_row-valuecolor = `Good`. |
| 49 | + INSERT ls_row INTO TABLE t_tab. |
| 50 | + ENDDO. |
| 51 | + |
| 52 | + ENDMETHOD. |
| 53 | + |
| 54 | + |
| 55 | + METHOD Z2UI5_IF_APP~MAIN. |
| 56 | + |
| 57 | + IF check_initialized = abap_false. |
| 58 | + check_initialized = abap_true. |
| 59 | + refresh_data( ). |
| 60 | + ENDIF. |
| 61 | + |
| 62 | + CASE client->get( )-event. |
| 63 | + |
| 64 | + WHEN 'GET_OPENED_COL'. |
| 65 | + DATA(lt_arg) = client->get( )-t_event_arg. |
| 66 | + |
| 67 | + WHEN 'ONSORT'. |
| 68 | + lt_arg = client->get( )-t_event_arg. |
| 69 | + |
| 70 | + |
| 71 | + WHEN 'ONGROUP'. |
| 72 | + |
| 73 | + WHEN 'SORT_ASCENDING'. |
| 74 | + SORT t_tab BY count ASCENDING. |
| 75 | + client->message_toast_display( 'sort ascending' ). |
| 76 | + |
| 77 | + WHEN 'SORT_DESCENDING'. |
| 78 | + SORT t_tab BY count DESCENDING. |
| 79 | + client->message_toast_display( 'sort descending' ). |
| 80 | + |
| 81 | + WHEN 'BACK'. |
| 82 | + client->nav_app_leave( ). |
| 83 | + |
| 84 | + ENDCASE. |
| 85 | + |
| 86 | + DATA(view) = z2ui5_cl_xml_view=>factory( ). |
| 87 | + DATA(page) = view->shell( |
| 88 | + )->page( |
| 89 | + title = 'abap2UI5 - table with column menu' |
| 90 | + navbuttonpress = client->_event( 'BACK' ) |
| 91 | + shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) |
| 92 | + ). |
| 93 | + |
| 94 | + DATA(tab) = page->scroll_container( height = '70%' vertical = abap_true |
| 95 | + )->table( |
| 96 | + growing = abap_true |
| 97 | + growingthreshold = '20' |
| 98 | + growingscrolltoload = abap_true |
| 99 | + items = client->_bind_edit( t_tab ) |
| 100 | + sticky = 'ColumnHeaders,HeaderToolbar' ). |
| 101 | + |
| 102 | + tab->header_toolbar( |
| 103 | + )->toolbar( |
| 104 | + )->title( 'title of the table' |
| 105 | + )->button( |
| 106 | + text = 'letf side button' |
| 107 | + icon = 'sap-icon://account' |
| 108 | + press = client->_event( 'BUTTON_SORT' ) |
| 109 | + )->segmented_button( selected_key = mv_key |
| 110 | + )->items( |
| 111 | + )->segmented_button_item( |
| 112 | + key = 'BLUE' |
| 113 | + icon = 'sap-icon://accept' |
| 114 | + text = 'blue' |
| 115 | + )->segmented_button_item( |
| 116 | + key = 'GREEN' |
| 117 | + icon = 'sap-icon://add-favorite' |
| 118 | + text = 'green' |
| 119 | + )->get_parent( )->get_parent( |
| 120 | + )->toolbar_spacer( |
| 121 | + )->button( |
| 122 | + icon = 'sap-icon://sort-descending' |
| 123 | + press = client->_event( 'SORT_DESCENDING' ) |
| 124 | + )->button( |
| 125 | + icon = 'sap-icon://sort-ascending' |
| 126 | + press = client->_event( 'SORT_ASCENDING' ) |
| 127 | + ). |
| 128 | + |
| 129 | +* column menu |
| 130 | + tab->dependents( |
| 131 | + )->column_menu( id = `menu` beforeopen = client->_event( val = `GET_OPENED_COL` t_arg = VALUE #( ( `$event.mParameters.openBy.getId()` ) ) ) |
| 132 | +* )->column_menu_quick_sort( change = client->_event( val = 'ONSORT' t_arg = VALUE #( ( `${$parameters>/item.getKey}` ) ) ) |
| 133 | +* )->column_menu_quick_sort( change = client->_event( val = 'ONSORT' t_arg = VALUE #( ( `$event` ) ) ) |
| 134 | + )->column_menu_quick_sort( change = client->_event( 'ONSORT' ) |
| 135 | + )->items( ns = `columnmenu` |
| 136 | + )->column_menu_quick_sort_item( |
| 137 | + )->get_parent( )->get_parent( )->get_parent( |
| 138 | + )->column_menu_quick_group( change = client->_event( 'ONGROUP' ) |
| 139 | + )->items( ns = `columnmenu` |
| 140 | + )->column_menu_quick_group_item( |
| 141 | + )->get_parent( )->get_parent( )->get_parent( |
| 142 | + )->items( ns = `columnmenu` |
| 143 | + )->column_menu_action_item( icon = `sap-icon://sort` label = `Sort` press = client->_event( 'ONSORTACTIONITEM' ) )->get_parent( |
| 144 | + )->column_menu_action_item( icon = `sap-icon://group-2` label = `Group` press = client->_event( 'ONSGROUPACTIONITEM' ) )->get_parent( |
| 145 | + )->column_menu_action_item( icon = `sap-icon://filter` label = `Filter` press = client->_event( 'ONSFILTERACTIONITEM' ) )->get_parent( |
| 146 | + )->column_menu_action_item( icon = `sap-icon://table-column` label = `Columns` press = client->_event( 'ONSCOLUMNSACTIONITEM' ) |
| 147 | + ). |
| 148 | + |
| 149 | + tab->columns( |
| 150 | + )->column( headermenu = `menu` id = `color_col` |
| 151 | + )->text( 'Color' )->get_parent( |
| 152 | + )->column( headermenu = `menu` id = `info_col` |
| 153 | + )->text( 'Info' )->get_parent( |
| 154 | + )->column( headermenu = `menu` id = `description_col` |
| 155 | + )->text( 'Description' )->get_parent( |
| 156 | + )->column( headermenu = `menu` id = `checkbox_col` |
| 157 | + )->text( 'Checkbox' )->get_parent( |
| 158 | + )->column( headermenu = `menu` id = `counter_col` |
| 159 | + )->text( 'Counter' )->get_parent( |
| 160 | + )->column( headermenu = `menu` id = `chart_col` |
| 161 | + )->text( 'Radial Micro Chart' ). |
| 162 | + |
| 163 | + tab->items( )->column_list_item( )->cells( |
| 164 | + )->text( '{VALUE}' |
| 165 | + )->text( '{INFO}' |
| 166 | + )->text( '{DESCR}' |
| 167 | + )->checkbox( selected = '{CHECKBOX}' enabled = abap_false |
| 168 | + )->text( '{COUNT}' |
| 169 | + ). |
| 170 | + |
| 171 | + client->view_display( view->stringify( ) ). |
| 172 | + |
| 173 | + ENDMETHOD. |
| 174 | +ENDCLASS. |
0 commit comments