From 446a64f453b4134c900cc84e02b37e719ada66ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=BCnter?= Date: Fri, 2 Feb 2024 15:22:31 +0100 Subject: [PATCH] popup_to_select fix sorter + parameterize (#838) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christian Günter --- src/02/03/z2ui5_cl_popup_to_select.clas.abap | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/02/03/z2ui5_cl_popup_to_select.clas.abap b/src/02/03/z2ui5_cl_popup_to_select.clas.abap index de4eb86d..28f6be83 100644 --- a/src/02/03/z2ui5_cl_popup_to_select.clas.abap +++ b/src/02/03/z2ui5_cl_popup_to_select.clas.abap @@ -10,6 +10,8 @@ CLASS z2ui5_cl_popup_to_select DEFINITION IMPORTING i_tab TYPE STANDARD TABLE i_title TYPE clike OPTIONAL + i_sort_field TYPE clike OPTIONAL + i_descending TYPE abap_bool OPTIONAL RETURNING VALUE(r_result) TYPE REF TO z2ui5_cl_popup_to_select. @@ -33,6 +35,8 @@ CLASS z2ui5_cl_popup_to_select DEFINITION DATA check_table_line TYPE abap_bool. DATA client TYPE REF TO z2ui5_if_client. DATA title TYPE string. + DATA sort_field TYPE string. + DATA descending TYPE abap_bool. METHODS on_event. METHODS display. METHODS set_output_table. @@ -51,6 +55,8 @@ CLASS z2ui5_cl_popup_to_select IMPLEMENTATION. r_result = NEW #( ). r_result->title = i_title. + r_result->sort_field = i_sort_field. + r_result->descending = i_descending. CREATE DATA r_result->mr_tab LIKE i_tab. CREATE DATA r_result->ms_result-row LIKE LINE OF i_tab. @@ -66,7 +72,11 @@ CLASS z2ui5_cl_popup_to_select IMPLEMENTATION. DATA(popup) = z2ui5_cl_xml_view=>factory_popup( ). DATA(tab) = popup->table_select_dialog( - items = `{path:'` && client->_bind_edit( val = path = abap_true ) && `', sorter : { path : 'STORAGE_LOCATION', descending : false } }` + items = `{path:'` + && client->_bind_edit( val = path = abap_true ) + && `', sorter : { path : '` && to_upper( sort_field ) && `', descending : ` + && z2ui5_cl_util_func=>boolean_abap_2_json( me->descending ) + && ` } }` cancel = client->_event( 'CANCEL' ) search = client->_event( val = 'SEARCH' t_arg = VALUE #( ( `${$parameters>/value}` ) ( `${$parameters>/clearButtonPressed}` ) ) ) confirm = client->_event( val = 'CONFIRM' t_arg = VALUE #( ( `${$parameters>/selectedContexts[0]/sPath}` ) ) )