Skip to Content
avatar image
Former Member

Create checkboxes dynamically

Hi all,

how can i create checkboxes in my view dynamically?

Please specify all classes i need...


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 12, 2008 at 07:35 AM


    You would basically need to perform the following steps:

    1) First get the reference of the ROOTUIELEMENTCONTAINER using get_root_element.

    2) Set the desired layout to the container using the obtained reference.

    3) Create an instance of the checkbox using the new_checkbox method of class cl_wd_checkbox.

    4) Specify the correct layout information to this newly created checkbox.

    5) Add the checkbox to the container ui element.

    You would have to mandatorily bind 2 properties of the created checkbox:

    bind_checked & bind_text.

    The state of the checkbox would get saved into the attribute specified by bind_checked

    The text to be displayed beside the checkbox would come from the attribute specified by bind_text

    Try insert the following coding into your WDDOMODIFYVIEW:

    METHOD wddomodifyview.
      DATA: lr_container TYPE REF TO cl_wd_uielement_container,
            lr_checkbox TYPE REF TO cl_wd_checkbox,
            lr_node TYPE REF TO if_wd_context_node.
      CHECK first_time = abap_true.
      lr_container ?= view->get_root_element( ).
      cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
      lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = 'NODE1.ATTR1' 
                                                  bind_text    = 'NODE1.ATTR2' ).
      cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
      lr_container->add_child( the_child = lr_checkbox ).



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Wolfgang Bauer,

      It is not possible to activate the checkbox without context once the checkbox is created.

      Use the methods BOUND_STATE/BOUND_TEXT from the class CL_WD_CHECKBOX to mark the checkbox with the context element.

      I think it should work.