Skip to content

Commit

Permalink
spreadsheet columnconfig as a property of xml view
Browse files Browse the repository at this point in the history
add column config array to custom control as a binded table instead of local json string.
(not breaking - kept the previous implementation version active as well)
  • Loading branch information
choper725 committed Apr 10, 2024
1 parent db6df23 commit 47e2295
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 7 deletions.
63 changes: 59 additions & 4 deletions src/01/05/z2ui5_cl_cc_spreadsheet.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ CLASS z2ui5_cl_cc_spreadsheet DEFINITION
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES z2ui5_if_ajson_filter.
CLASS-METHODS get_js
IMPORTING
!i_columnconfig TYPE clike
!i_columnconfig TYPE clike OPTIONAL
RETURNING
VALUE(r_js) TYPE string .
VALUE(r_js) TYPE string .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
Expand All @@ -20,6 +20,11 @@ CLASS Z2UI5_CL_CC_SPREADSHEET IMPLEMENTATION.


METHOD get_js.
DATA lv_column_config TYPE string.
lv_column_config = i_columnconfig.
IF lv_column_config IS INITIAL.
lv_column_config = `''`.
ENDIF.

r_js = ` sap.ui.define("z2ui5/ExportSpreadsheet" , [` && |\n| &&
` "sap/ui/core/Control",` && |\n| &&
Expand All @@ -44,6 +49,9 @@ CLASS Z2UI5_CL_CC_SPREADSHEET IMPLEMENTATION.
` type: "string",` && |\n| &&
` defaultValue: ""` && |\n| &&
` },` && |\n| &&
` columnconfig: { ` && |\n| &&
` type: "Array" ` && |\n| &&
` },` && |\n| &&
` text: {` && |\n| &&
` type: "string",` && |\n| &&
` defaultValue: ""` && |\n| &&
Expand All @@ -57,6 +65,12 @@ CLASS Z2UI5_CL_CC_SPREADSHEET IMPLEMENTATION.
` renderer: null` && |\n| &&
` },` && |\n| &&
|\n| &&
` setColumnconfig: function(oConfig) { ` && |\n| &&
`debugger;` && |\n| &&
* ` oConfig = JSON.parse(oConfig);` && |\n| &&
` this.setProperty("columnconfig", oConfig, true );` && |\n| &&
` },` && |\n| &&
|\n| &&
` renderer: function (oRm, oControl) {` && |\n| &&
|\n| &&
` oControl.oExportButton = new Button({` && |\n| &&
Expand All @@ -66,7 +80,8 @@ CLASS Z2UI5_CL_CC_SPREADSHEET IMPLEMENTATION.
` press: function (oEvent) { ` && |\n| &&
|\n| &&
`debugger;` && |\n| &&
` var aCols =` && i_columnconfig && `;` && |\n| &&
` var aCols = oControl.getProperty("columnconfig");` && |\n| &&
` if( !aCols ) { aCols = ` && lv_column_config && `; }` && |\n| &&
|\n| &&
` var oBinding, oSettings, oSheet, vTableId, vViewPrefix,vPrefixTableId;` && |\n| &&
` vTableId = oControl.getProperty("tableId")` && |\n| &&
Expand Down Expand Up @@ -100,4 +115,44 @@ CLASS Z2UI5_CL_CC_SPREADSHEET IMPLEMENTATION.
` });`.

ENDMETHOD.


METHOD z2ui5_if_ajson_filter~keep_node.

rv_keep = abap_true.

CASE iv_visit.

WHEN z2ui5_if_ajson_filter=>visit_type-open.

IF is_node-children = 0.
rv_keep = abap_false.
ENDIF.

WHEN z2ui5_if_ajson_filter=>visit_type-value.

CASE is_node-type.
WHEN z2ui5_if_ajson_types=>node_type-boolean.
IF is_node-value = `false`.
rv_keep = abap_false.
ENDIF.
WHEN z2ui5_if_ajson_types=>node_type-number.
IF is_node-value = `0` OR is_node-value = `0.00`.
rv_keep = abap_false.
ENDIF.
WHEN z2ui5_if_ajson_types=>node_type-string.
IF is_node-value = ``.
rv_keep = abap_false.
ENDIF.
ENDCASE.

WHEN z2ui5_if_ajson_filter=>visit_type-close.

IF is_node-children = 0.
rv_keep = abap_false.
ENDIF.

ENDCASE.

ENDMETHOD.
ENDCLASS.
8 changes: 5 additions & 3 deletions src/02/01/01/z2ui5_cl_xml_view_cc.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION
!type TYPE clike OPTIONAL
!text TYPE clike OPTIONAL
!icon TYPE clike OPTIONAL
!columnconfig TYPE clike OPTIONAL
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .

Expand Down Expand Up @@ -435,9 +436,10 @@ CLASS Z2UI5_CL_XML_VIEW_CC IMPLEMENTATION.
mo_view->_generic( name = `ExportSpreadsheet`
ns = `z2ui5`
t_prop = VALUE #( ( n = `tableId` v = tableid )
( n = `text` v = text )
( n = `icon` v = icon )
( n = `type` v = type )
( n = `text` v = text )
( n = `icon` v = icon )
( n = `type` v = type )
( n = `columnconfig` v = columnconfig )
) ).

ENDMETHOD.
Expand Down

0 comments on commit 47e2295

Please sign in to comment.