cancel
Showing results for 
Search instead for 
Did you mean: 

Operations on dynamically created checkboxes

Former Member
0 Kudos

Hi Experts,

In my application I have created 10 check boxes dynamically. All check boxes are for selecting different request types which the user can select. Out of these 10 one check box is for "ALL requests". Now I want that if All Check box is clicked all other checkboxes must be checked. I want to use on toggle action of checkboxes on dynamicaaly created checkboxes Is it possible? Or I have to create checkboxes statically and only then I can use ontoggle action of checkboxes..

Please help me in this regard.

Thanks,

Pratibha

Accepted Solutions (1)

Accepted Solutions (1)

arjun_thakur
Active Contributor
0 Kudos

Hi Pratibha,

Creating static check boxes can be done.

But if you want to go for the dynamically created checkbox refer this thread:

I hope it helps.

Regards

Arjun

Former Member
0 Kudos

Hi,

I have created a node node1 with three string attributes namely str1 , str2 and str3.

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 ).

  DATA lo_nd_node TYPE REF TO if_wd_context_node.
  DATA lo_el_node TYPE REF TO if_wd_context_element.
  DATA ls_node TYPE wd_this->element_node.
  DATA lv_str3 LIKE ls_node-str3.
* navigate from <CONTEXT> to <NODE> via lead selection
  lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

* get element via lead selection
  lo_el_node = lo_nd_node->get_element(  ).

* get single attribute
  lo_el_node->set_attribute(
    EXPORTING
      name =  `STR3`
      value = 'ONTOGGLE' ).

* navigate from <CONTEXT> to <NODE> via lead selection
  lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

* get element via lead selection
  lo_el_node = lo_nd_node->get_element(  ).

* get all declared attributes
  lo_el_node->get_static_attributes(
    IMPORTING
      static_attributes = ls_node ).



  lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = ls_node-str1
                                              bind_text    = ls_node-str2
                                              ON_TOGGLE =    lv_str3  ).

  cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
  lr_container->add_child( the_child = lr_checkbox ).

This code is giving me error : " No access possible via the 'NULL' data reference :"

Former Member
0 Kudos

hi ,

I am trying this piece of code :


lo_container ?= wd_this->mr_view->get_element( 'TC_SYSTEM' ).

where mr_view is my attribute declared in ATTRIBUTE tab of type IF_WD_VIEW and TC_SYSTEM is the transparent container in the root element container in which I wish to insert the UI .

either u write the code to generate the dynamic UIs in ur WD DOMODIFY or some action of button .

also pass this view parameter here


lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = ls_node-str1
                                              bind_text    = ls_node-str2
                                              ON_TOGGLE =    lv_str3 
                                              view = wd_this->mr_view   ).

regards,

amit

Former Member
0 Kudos

Hi Amit,

I have written following code in wddomodifyview. I have declared mr_view as attribute in my view and in component controller of the type IF_WD_VIEW.

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( ).

  lr_container ?= wd_this->mr_view->get_element( 'TC' ).

  cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).

  DATA lo_nd_node TYPE REF TO if_wd_context_node.
  DATA lo_el_node TYPE REF TO if_wd_context_element.
  DATA ls_node TYPE wd_this->element_node.
  DATA lv_str3 LIKE ls_node-str3.
  DATA lv_str1 LIKE ls_node-str1.
  DATA lv_str2 LIKE ls_node-str2.




* navigate from <CONTEXT> to <NODE> via lead selection
  lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

* get element via lead selection
  lo_el_node = lo_nd_node->get_element(  ).

* get single attribute
  lo_el_node->set_attribute(
    EXPORTING
      name =  `STR3`
      value = 'ON_TOGGLE' ).

  lo_el_node->set_attribute(
EXPORTING
 name =  `STR1`
 value = 'ALL_REQ' ).

  lo_el_node->set_attribute(
 EXPORTING
   name =  `STR2`
   value = 'DYNAMIC.ALL_REQ' ).

* navigate from <CONTEXT> to <NODE> via lead selection
  lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

* get element via lead selection
  lo_el_node = lo_nd_node->get_element(  ).

* get all declared attributes
  lo_el_node->get_static_attributes(
    IMPORTING
      static_attributes = ls_node ).

  ls_node-str1 = lv_str1.
  ls_node-str2 = lv_str2.
  ls_node-str3 = lv_str3.
  lo_el_node->set_static_attributes(
    EXPORTING
      static_attributes = ls_node ).


  lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = ls_node-str2
                                              bind_text    = ls_node-str1
                                              on_toggle =    ls_node-str3
                                              view = wd_this->mr_view   ).

  cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
  lr_container->add_child( the_child = lr_checkbox ).



ENDMETHOD.

I am getting this error : Access via 'NULL' object reference not possible

pls help.

Thanks,

Pratibha

Answers (3)

Answers (3)

Former Member
0 Kudos

answered

Former Member
0 Kudos

answered

Former Member
0 Kudos

hi,

for your dynamically generated checkboxes , u can use use the set_attribute method to set the context attribute to a value 'X'

to mark the checkbox as checked , and ' ' (blank) to set the checkbox in disabled mode ..

u cn do it in the same way, as u do it for the static context attribute under the context node

regards,

amit