Google Search - Blog...........

ABAP - Handling Radio Buttons in SALV Tree Display.


This tutorial will help developers to handle checkboxes in SALV tree.
I would be copying some code verbatim from my project work.

Following code is to add checkboxes in ALV tree:

FORM add_root_request USING _p_ls_data_ TYPE csg_gs_outtab_p_key__l_is_sub_node_ TYPE c

CHANGING _p_l_carrid_key._node = nodes->add_node( related_node = p_key
relationship = cl_gui_column_tree=>relat_last_child ).

* ... §0.2 if information should be displayed at

* the hierarchy column set the carrid as text for this node
text = p_ls_data-object.
node->set_text( text ).

* ... §0.3 set the data for the nes node
node->set_data_row( p_ls_data ).
item = node->get_hierarchy_item( ).
item = node->get_item( 'FCHECKBOX' ). "FCHECKBOX is my radio button field in internal table which I am using to populate the ALV
item->set_type( if_salv_c_item_type=>checkbox ).
_p_l_carrid_key = node->get_key( )._

CATCH cx_salv_msg.

ENDFORM_._
Following code is for handling checbox_change event
PERFORM application_action_events.
FORM application_action_events .

data: lr_events type ref to cl_salv_events_tree.

*data gr_events type ref to lcl_handle_events.

lr_events = gr_tree->get_event( ).

create object gr_events.

set handler gr_events->check for lr_events.

* set handler gr_events->on_link_click for lr_events.

*

* set handler gr_events->on_before_user_command for lr_events.

*

* set handler gr_events->on_after_user_command for lr_events.

*

* set handler gr_events->on_keypress for lr_events.

endform. " application_action_events---------------------------------------------------------------------------------------

CLASS lcl_handle_events DEFINITION.

PUBLIC SECTION.

METHODS:

check FOR EVENT checkbox_change OF cl_salv_events_tree IMPORTING node_key columnname checked. "Here node_key is the row number

ENDCLASS. "lcl_handle_events DEFINITION

*---------------------------------------------------------------------*

* CLASS lcl_handle_events IMPLEMENTATION

*---------------------------------------------------------------------*

* §4.2 implement the events for handling the events of cl_salv_table

*---------------------------------------------------------------------*

CLASS lcl_handle_events IMPLEMENTATION_._

METHOD check_._

WRITE 'hello'_._

DATA _l_wa_modify_check_ TYPE REF TO csg_gs_outtab.

node_key = node_key - 1_._

READ TABLE csg_gt_list INDEX node_key REFERENCE INTO _l_wa_modify_check._

if columnname = 'FCHECKBOX'_._

IF checked = 'X'_._

* If the value in internal table is set to X, then it is deselct

_l_wa_modify_check->fcheckbox =_ ' '_._

ELSE_._

_l_wa_modify_check->fcheckbox =_ 'X'_._

ENDIF_._

ENDIF_._

if columnname = 'CHECKBOX_READ'_._

IF checked = 'X'_._

* If the value in internal table is set to X, then it is deselct

_l_wa_modify_check->checkbox_read =_ ' '_._

ELSE_._

_l_wa_modify_check->checkbox_read =_ 'X'_._

ENDIF_._

ENDIF_._

*MODIFY TABLE csg_gt_list from l_wa_modify_check.

flag_test = flag_test + 1_._

ENDMETHOD_._ "check

ENDCLASS_._ "lcl_handle_events IMPLEMENTATION



ALSO READ:

- Implementing F4 Search Help In OO ALV Grid Display.

- List Of Transport Requests In ALV Format.

- ALV Report With User Defined Buttons In It's Toolbar.

- ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC.

..... Back To Index On ALV List/ Grid Display.

..... Back To MAIN INDEX.


No comments:

Post a Comment