2011 Jun 21 8:24 AM
Hi all,
I have a ALV Tree with editable checkbox (for all the parent & leaf nodes) , as one of the column.On clicking of a button in toolbar , i should get the nodes which are checked in checkbox.
But the problem is i am not able to get the nodes which are checked through checkbox in the PAI of the screen,when the button is clicked.
I tried using
CALL METHOD wf_tree->get_checked_items
IMPORTING
et_checked_items = lint_selected_node.but the return table is not containing any entries , even if check boxes are checked in ALV tree.I tried the GET_CHECKED_ITEMS method in event handler method of AFTER_USER_COMMAND and also CHECKBOX_CHANGE , but no success.
lfs_item_layout-fieldname = 'CHECK'.
lfs_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
lfs_item_layout-editable = 'X'.
lfs_item_layout-CHOSEN = 'X'.
APPEND lfs_item_layout TO lint_item_layout.
CALL METHOD wf_tree->add_node
EXPORTING
i_relat_node_key = p_lfs_final_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = p_gfs_final
is_node_layout = lfs_node
it_item_layout = lint_item_layout
IMPORTING
e_new_node_key = p_loc_qmnum_key.Friends ,if you can suggest something.
Thanks
Abhijeet
Hi all,
I have a ALV Tree with editable checkbox (for all the parent & leaf nodes) , as one of the column.On clicking of a button in toolbar , i should get the nodes which are checked in checkbox.
But the problem is i am not able to get the nodes which are checked through checkbox in the PAI of the screen,when the button is clicked.
I tried using
CALL METHOD wf_tree->get_checked_items
IMPORTING
et_checked_items = lint_selected_node.but the return table is not containing any entries , even if check boxes are checked in ALV tree.I tried the GET_CHECKED_ITEMS method in event handler method of AFTER_USER_COMMAND and also CHECKBOX_CHANGE , but no success.
lfs_item_layout-fieldname = 'CHECK'.
lfs_item_layout-class = cl_gui_column_tree=>item_class_checkbox.
lfs_item_layout-editable = 'X'.
lfs_item_layout-CHOSEN = 'X'.
APPEND lfs_item_layout TO lint_item_layout.
CALL METHOD wf_tree->add_node
EXPORTING
i_relat_node_key = p_lfs_final_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = p_gfs_final
is_node_layout = lfs_node
it_item_layout = lint_item_layout
IMPORTING
e_new_node_key = p_loc_qmnum_key.Friends ,if you can suggest something.
Thanks
Abhijeet
2011 Jun 21 11:54 AM
2011 Jun 21 12:49 PM
but i am not getting any values in lint_selected_node
CALL METHOD wf_tree->get_checked_items
IMPORTING
et_checked_items = lint_selected_node.
2011 Jun 21 1:23 PM
implement EVENTID_CHECKBOX_CHANGE method. each time this event is triggered you have to insert node key into your new internal table or revome it if it exist. and when PAI is activated just read data from that table.
best regards,
dez_
2011 Jun 21 5:59 PM
hi ,
i have written below code for registering the CHECKBOX_CHANGE event of CL_GUI_ALV_TREE.
APPEND lfs_event TO lint_events.
lfs_event-eventid = cl_gui_column_tree=>eventid_CHECKBOX_CHANGE.
APPEND lfs_event TO lint_events.
CALL METHOD wf_tree->set_registered_events
EXPORTING
events = lint_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc EQ 0.
* MESSAGE X208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
SET HANDLER lo_event_receiver->handle_checkbox_change FOR wf_tree.
* SET HANDLER lo_event_receiver->handle_button_click FOR wf_tree.
ENDIF.Also according to below code , i have put a break point in the event handler method of CHECKBOX_CHANGE event , so that control shall come here when check box is checked on ALV tree ...
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
* handle_checkbox_change FOR EVENT checkbox_change OF cl_gui_alv_tree,
* importing fcode.
* handle_button_click FOR EVENT AFTER_USER_COMMAND OF cl_gui_alv_tree
* IMPORTING ucomm,
handle_CHECKBOX_CHANGE for event checkbox_change of cl_gui_alv_tree
importing CHECKED
FIELDNAME
NODE_KEY.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_checkbox_change.
data : lint_selected_node TYPE LVC_T_CHIT.
BREAK abhijeetg.
* CHECKED
* FIELDNAME
* NODE_KEY
* case fcode.
* when 'SELALL'.
* perform select_all.
* CALL METHOD WF_TREE->GET_OUTTAB_LINE
* EXPORTING
* I_NODE_KEY =
** IMPORTING
** e_outtab_line =
** e_node_text =
** et_item_layout =
** es_node_layout =
** EXCEPTIONS
** node_not_found = 1
** others = 2
* .
* IF SY-SUBRC <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
* call method cl_gui_cfw=>dispatch.
CALL METHOD wf_tree->get_checked_items
IMPORTING
et_checked_items = lint_selected_node.
break abhijeetg.
ENDMETHOD.
ENDCLASS.So according to you , I should get the control in the break point , but its not happening with this .. any thing missing ???
Edited by: abhijeet_7013 on Jun 21, 2011 10:31 PM
2011 Jun 21 6:54 PM
Is the event handing working at all?
Put breakpoint in event handler method
2011 Jun 21 7:40 PM
break point is already there...
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_checkbox_change.
data : lint_selected_node TYPE LVC_T_CHIT.
BREAK abhijeetg.but control not cuming in this method ,, dont know
Edited by: abhijeet_7013 on Jun 22, 2011 12:11 AM
2011 Jun 22 12:05 PM
hello ,
you could retrieve checkbox value via item_layout-chosen (method get_outtab_line) field it could be empty or 'X'.
best regards,
dez_
2011 Jun 22 7:12 PM
hi thanks for replies
CHECKBOX_CHANGE and ITEM_KEYPRESS events i tried , none are triggering ,
any other way out ,,, pls suggest ,, thanks
2011 Jun 22 8:02 PM
To register it you need
DATA lt_events TYPE cntl_simple_events.
DATA wa_event TYPE cntl_simple_event.
wa_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
wa_event-appl_event = 'X'.
APPEND wa_event TO lt_events.
go_alv_tree->set_registered_events( lt_events ).
CREATE OBJECT go_tree_handler.
SET HANDLER go_tree_handler->handle_checkbox_change FOR go_alv_tree.
In handler method
METHOD handle_checkbox_change.
DATA lt_item_layout TYPE lvc_t_layi.
DATA lt_new_item_layout TYPE lvc_t_laci.
DATA lt_subnodes TYPE lvc_t_nkey.
DATA wa_item_layout TYPE lvc_s_layi.
DATA wa_new_item_layout TYPE lvc_s_laci.
FIELD-SYMBOLS <subnode> TYPE lvc_nkey.
go_alv_tree->GET_SUBTREE( EXPORTING I_NODE_KEY = node_key
IMPORTING ET_SUBTREE_NODES = lt_subnodes ).
LOOP AT lt_subnodes ASSIGNING <subnode>.
go_alv_tree->get_outtab_line( EXPORTING i_node_key = <subnode>
IMPORTING e_outtab_line = wa_newobject
et_item_layout = lt_item_layout ).
READ TABLE lt_item_layout INTO wa_item_layout INDEX 1.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_item_layout TO wa_new_item_layout.
wa_new_item_layout-chosen = checked.
wa_new_item_layout-u_chosen = 'X'.
wa_newobject-export_u = checked.
APPEND wa_new_item_layout TO lt_new_item_layout.
go_alv_tree->change_node( i_node_key = <subnode>
it_item_layout = lt_new_item_layout
i_outtab_line = wa_newobject ).
REFRESH lt_new_item_layout.
REFRESH lt_item_layout.
ENDIF.
ENDLOOP.
ENDMETHOD. "handle_checkbox_changed
Regards
Marcin
2011 Jun 22 8:47 PM
hi ,
solved the problem ,,, jst required to give ITEM_SELECTION = 'X' while creating tree object... thats why CHECKBOX_CHANGE event was not trigerring earlier.....
* create tree control
CREATE OBJECT wf_tree
EXPORTING
parent = wf_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple
item_selection = 'X'
no_html_header = 'X'
no_toolbar = space
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.thanks friends for your replies and time
regards,
abhijeet