Работа с CL_LIST_TREE_MODEL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
" http://saphelp.ucc.ovgu.de/NW750/EN/4d/88f020981740abe10000000a15822b/frameset.htm CLASS lcl_events DEFINITION. PUBLIC SECTION. TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY. CLASS-METHODS: on_button_click FOR EVENT button_click OF cl_list_tree_model IMPORTING node_key item_name sender. CLASS-METHODS: on_link_click FOR EVENT link_click OF cl_list_tree_model IMPORTING node_key item_name sender. CLASS-METHODS: on_checkbox_change FOR EVENT checkbox_change OF cl_list_tree_model IMPORTING node_key item_name checked sender. CLASS-METHODS: on_header_click FOR EVENT header_click OF cl_list_tree_model IMPORTING header_name sender. ENDCLASS. CLASS lcl_events IMPLEMENTATION. METHOD on_button_click. MESSAGE node_key && '_' && item_name TYPE 'S'. ENDMETHOD. METHOD on_link_click. MESSAGE node_key && '_' && item_name TYPE 'S'. ENDMETHOD. METHOD on_checkbox_change. MESSAGE node_key && '_' && item_name && '_' && checked TYPE 'S'. ENDMETHOD. METHOD on_header_click. MESSAGE header_name TYPE 'S'. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA(o_tree) = NEW cl_list_tree_model( node_selection_mode = cl_list_tree_model=>node_sel_mode_single item_selection = abap_true with_headers = abap_true hierarchy_header = VALUE #( t_image = icon_folder heading = 'Заголовок' tooltip = 'Tooltip' width = 80 ) ). o_tree->create_tree_control( parent = cl_gui_container=>default_screen ). o_tree->add_node( EXPORTING isfolder = abap_true node_key = 'NODE1' relative_node_key = '' relationship = cl_tree_model=>relat_last_child expanded_image = CONV tv_image( icon_folder ) image = CONV tv_image( icon_folder ) item_table = VALUE #( ( class = cl_list_tree_model=>item_class_checkbox item_name = '1' text = 'Obj1' editable = abap_true length = 10 ) ) ). o_tree->add_node( EXPORTING isfolder = abap_false node_key = 'NODE1_1' relative_node_key = 'NODE1' relationship = cl_tree_model=>relat_last_child expanded_image = CONV tv_image( icon_oo_object ) image = CONV tv_image( icon_oo_object ) item_table = VALUE #( ( class = cl_list_tree_model=>item_class_link item_name = '1' text = 'Obj4' length = 10 ) ( class = cl_list_tree_model=>item_class_text item_name = '2' text = 'Wert1' length = 10 ) ( class = cl_list_tree_model=>item_class_text item_name = '3' text = 'Wert2' length = 10 alignment = cl_list_tree_model=>align_auto font = cl_list_tree_model=>item_font_prop ) ) ). o_tree->add_node( EXPORTING isfolder = abap_true node_key = 'NODE2' relative_node_key = '' relationship = cl_tree_model=>relat_last_child expanded_image = CONV tv_image( icon_folder ) image = CONV tv_image( icon_folder ) item_table = VALUE #( ( class = cl_list_tree_model=>item_class_checkbox item_name = '1' text = 'Obj2' editable = abap_true length = 10 ) ) ). o_tree->add_node( EXPORTING isfolder = abap_false node_key = 'NODE2_1' relative_node_key = 'NODE2' relationship = cl_tree_model=>relat_last_child expanded_image = CONV tv_image( icon_oo_object ) image = CONV tv_image( icon_oo_object ) item_table = VALUE #( ( class = cl_list_tree_model=>item_class_button item_name = '1' text = 'Obj3' length = 10 ) ( class = cl_list_tree_model=>item_class_text item_name = '2' text = 'Wert1' length = 10 ) ( class = cl_list_tree_model=>item_class_text item_name = '3' text = 'Wert2' length = 10 alignment = cl_list_tree_model=>align_auto font = cl_list_tree_model=>item_font_prop ) ) ). o_tree->expand_root_nodes( expand_subtree = abap_true level_count = 10 ). SET HANDLER lcl_events=>on_button_click FOR o_tree. SET HANDLER lcl_events=>on_checkbox_change FOR o_tree. SET HANDLER lcl_events=>on_header_click FOR o_tree. SET HANDLER lcl_events=>on_link_click FOR o_tree. DATA(it_events) = VALUE lcl_events=>ty_it_events( ( eventid = cl_list_tree_model=>eventid_button_click appl_event = abap_true ) ( eventid = cl_list_tree_model=>eventid_checkbox_change appl_event = abap_true ) ( eventid = cl_list_tree_model=>eventid_header_click appl_event = abap_true ) ( eventid = cl_list_tree_model=>eventid_link_click appl_event = abap_true ) ). o_tree->set_registered_events( events = it_events ). WRITE: space. |
Результат: