Skip to content

tree sample #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile( header = 'Tree Table IV'
subheader = 'Drag & Drop'
press = client->_event( 'z2ui5_cl_demo_app_116' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

page = page2->panel( expandable = abap_true
expanded = client->_bind_edit( ms_check_expanded-popups )
headertext = `Popups & Popovers` ).
Expand Down
15 changes: 9 additions & 6 deletions src/z2ui5_cl_demo_app_035.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ CLASS z2ui5_cl_demo_app_035 DEFINITION PUBLIC.
DATA check_initialized TYPE abap_bool.

DATA client TYPE REF TO z2ui5_if_client.

DATA: lt_types TYPE z2ui5_if_types=>ty_t_name_value.
METHODS view_display.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.


Expand All @@ -34,13 +35,13 @@ CLASS z2ui5_cl_demo_app_035 IMPLEMENTATION.
)->input( client->_bind_edit( mv_path )
)->label( 'Option' ).

DATA(lt_types) = VALUE z2ui5_if_types=>ty_t_name_value( ).
lt_types = VALUE #( FOR row IN z2ui5_cl_util=>source_get_file_types( ) (
lt_types = VALUE z2ui5_if_types=>ty_t_name_value( ).
LT_TYPES = VALUE #( FOR row IN z2ui5_cl_util=>source_get_file_types( ) (
n = shift_right( shift_left( row ) )
v = shift_right( shift_left( row ) ) ) ).

DATA(temp3) = temp->input( value = client->_bind_edit( mv_type )
suggestionitems = client->_bind_local( lt_types )
suggestionitems = client->_bind_local( LT_TYPES )
)->get( ).

temp3->suggestion_items(
Expand All @@ -51,8 +52,8 @@ CLASS z2ui5_cl_demo_app_035 IMPLEMENTATION.
press = client->_event( 'DB_LOAD' )
icon = 'sap-icon://download-from-cloud' ).

page->code_editor( type = mv_type
editable = mv_check_editable
page->code_editor( type = client->_bind_edit( mv_type )
editable = client->_bind( mv_check_editable )
value = client->_bind( mv_editor ) ).

page->footer( )->overflow_toolbar(
Expand Down Expand Up @@ -102,6 +103,8 @@ CLASS z2ui5_cl_demo_app_035 IMPLEMENTATION.
type = 'success' ).
WHEN 'EDIT'.
mv_check_editable = xsdbool( mv_check_editable = abap_false ).
client->view_model_update( ).

WHEN 'CLEAR'.
mv_editor = ``.
WHEN 'BACK'.
Expand Down
165 changes: 165 additions & 0 deletions src/z2ui5_cl_demo_app_317.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
CLASS z2ui5_cl_demo_app_317 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
INTERFACES z2ui5_if_app.

TYPES:
BEGIN OF ty_node4,
id TYPE string,
text TYPE string,
* nodes TYPE STANDARD TABLE OF ty_node5 WITH DEFAULT KEY,
END OF ty_node4,
BEGIN OF ty_node3,
id TYPE string,
text TYPE string,
nodes TYPE STANDARD TABLE OF ty_node4 WITH DEFAULT KEY,
END OF ty_node3,
BEGIN OF ty_node2,
id TYPE string,
text TYPE string,
nodes TYPE STANDARD TABLE OF ty_node3 WITH DEFAULT KEY,
END OF ty_node2,
BEGIN OF ty_node1,
id TYPE string,
text TYPE string,
nodes TYPE STANDARD TABLE OF ty_node2 WITH DEFAULT KEY,
END OF ty_node1,
ty_tree TYPE STANDARD TABLE OF ty_node1 WITH DEFAULT KEY.
DATA mt_tree TYPE ty_tree.

TYPES:
BEGIN OF ty_S_node,
id TYPE string,
id_parent TYPE string,
text TYPE string,
END OF ty_S_node.
DATA mt_node TYPE STANDARD TABLE OF ty_S_node WITH EMPTY KEY.

PROTECTED SECTION.
METHODS build_tree.
METHODS display_view
IMPORTING
client TYPE REF TO z2ui5_if_client.

ENDCLASS.

CLASS z2ui5_cl_demo_app_317 IMPLEMENTATION.

METHOD z2ui5_if_app~main.

IF client->check_on_init( ).

mt_node = VALUE #(
( id = '01' id_parent = '' text = 'Machines' )
( id = '03' id_parent = '01' text = 'Pumps' )
( id = '04' id_parent = '03' text = 'Pump 001' )
( id = '05' id_parent = '03' text = 'Pump 002' )
( id = '02' id_parent = '' text = 'Paints' )
( id = '06' id_parent = '02' text = 'Gloss paints' )
( id = '07' id_parent = '06' text = 'Paint 001' )
( id = '08' id_parent = '06' text = 'Paint 002' ) ).

build_tree( ).
display_view( client ).

ENDIF.

CASE client->get( )-event.

WHEN 'expand'.
client->follow_up_action( `debugger; z2ui5.oView.byId( 'tree' ).expandToLevel(10);`).

WHEN 'onDrop'.
mt_node[ id = client->get_event_arg( 1 ) ]-id_parent = client->get_event_arg( 2 ).
build_tree( ).
display_view( client ).
ENDCASE.


ENDMETHOD.

METHOD build_tree.

CLEAR mt_tree.
LOOP AT mt_node INTO DATA(ls_node) WHERE id_parent IS INITIAL.

DATA(ls_root) = CORRESPONDING ty_node1( ls_node ).
INSERT ls_root INTO TABLE mt_tree.

ENDLOOP.


LOOP AT mt_tree REFERENCE INTO DATA(lr_node).

LOOP AT mt_node INTO ls_node WHERE id_parent = lr_node->id.
DATA(ls_root2) = CORRESPONDING ty_node2( ls_node ).
INSERT ls_root2 INTO TABLE lr_node->nodes.
ENDLOOP.

ENDLOOP.


LOOP AT mt_tree REFERENCE INTO lr_node.
LOOP AT lr_node->nodes REFERENCE INTO DATA(lr_node2).

LOOP AT mt_node INTO ls_node WHERE id_parent = lr_node2->id.
DATA(ls_root3) = CORRESPONDING ty_node3( ls_node ).
INSERT ls_root3 INTO TABLE lr_node2->nodes.
ENDLOOP.

ENDLOOP.
ENDLOOP.


LOOP AT mt_tree REFERENCE INTO lr_node.
LOOP AT lr_node->nodes REFERENCE INTO lr_node2.
LOOP AT lr_node2->nodes REFERENCE INTO DATA(lr_node3).

LOOP AT mt_node INTO ls_node WHERE id_parent = lr_node3->id.
DATA(ls_root4) = CORRESPONDING ty_node4( ls_node ).
INSERT ls_root4 INTO TABLE lr_node3->nodes.
ENDLOOP.

ENDLOOP.
ENDLOOP.
ENDLOOP.

ENDMETHOD.


METHOD display_view.

DATA(page) = z2ui5_cl_xml_view=>factory( )->page( ).

page->_generic( name = `script` ns = `html`
)->_cc_plain_xml(
|function myFunction() \{ z2ui5.oView.byId('tree').expandToLevel(5); \}|
).

DATA(tree) = page->tree( items = client->_bind( mt_tree ) id = `tree` ).
tree->items(
)->standard_tree_item( title = '{TEXT}'
)->get(
)->custom_data(
)->core_custom_data( key = 'ID' value = '{ID}').

tree->drag_drop_config( ns = `` )->Drag_Drop_Info(

Check failure on line 149 in src/z2ui5_cl_demo_app_317.clas.abap

View check run for this annotation

abaplint / abaplint

Method importing parameter "NS" does not exist

https://rules.abaplint.org/check_syntax

Check failure on line 149 in src/z2ui5_cl_demo_app_317.clas.abap

View check run for this annotation

abaplint / abaplint

Method "Drag_Drop_Info" not found, methodCallChain

https://rules.abaplint.org/check_syntax
sourceAggregation = `items`
targetAggregation = `items`
dragStart = `Horizontal`
drop = client->_event(
val = 'onDrop'
t_arg = VALUE #(
( `${$parameters>/draggedControl/mAggregations/customData/0/mProperties/value}` )
( `${$parameters>/droppedControl/mAggregations/customData/0/mProperties/value}` )
) ) ).

client->follow_up_action( `myFunction()` ).
client->view_display( page->stringify( ) ).

ENDMETHOD.

ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_317.clas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_DEMO_APP_317</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>tab -different odata models</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
Loading
Loading