cancel
Showing results for 
Search instead for 
Did you mean: 

How to check a check box in checkboxgroup on load?

0 Kudos

Hi!

How do you go about setting one or more checkboxes of a checkboxgroup as checked on load? The checkbox group is inside a pop-up and the view is dynamically built. I don't seem to have any option to achieve it from CL_WD_CHECKBOX_GROUP at least. Guess then the only way will be read the elements individually and set them as checked?

Thanks,

Praveen

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

In WDDOINIT method, after initializing and binding the check box group using bind_table, you can use set_lead_selection_index( 2 ) ( 2 is to default 2nd check box selected) method of context node.

hope this helps,

Regards,

Kiran

0 Kudos

Hi Kiran,

I'm sorry but I'm missing something here...

In WDDOINIT, I only have my mapping paths defined... Mapping the component controller context with the view context. The view itself I have built in WDDOMODIFY using 'CALL METHOD cl_wd_checkbox_group=>new_checkbox_group' and passing the bind_texts parameter to bind the text of course.

I'm not quite sure where does 'bind_table' or 'set_lead_selection' fits in here... Neither are they part of the ' CL_WD_CHECKBOX_GROUP' class... Can you expand or point me to an example?

Thanks,

Praveen

former_member184578
Active Contributor
0 Kudos

Hi,

Are you creating the context node dynamically? If not, then in your wddomodify view method, inside if first_time = Abap_true.

after binding check box texts,

use

lo_nd_node->set_lead_selection_index() method '' here node is the name of context nose to which the checkbox group texts is bound

Regards,

Kiran

0 Kudos

Hi Kiran!

But yes, the context node is dynamically created too. But I will explore more to see if I can use set_lead_selection_index somehow here also keeping in mind that I'd like multiple checkboxes to be set and not just one.

Thanks,

Praveen

former_member184578
Active Contributor
0 Kudos

Hi,

If you want to set multiple checkbox's you can use set_selected( ) method of context element by looping the check box texts.

Let say you are binding the checkbox texts from an internal table lt_check.

And your context node is say, CHECK

Then,

  


DATA lo_nd_check TYPE REF TO if_wd_context_node.

  DATA lo_el_check TYPE REF TO if_wd_context_element.

   lo_nd_check = wd_context->get_child_node( name = wd_this->wdctx_check ).

    LOOP AT lt_check INTO ls_check. " Loop check bx texts

         lo_el_check = lo_nd_check->get_element( sy-tabix ).

     

        Based on your condition set the check box.

Say you want to set 2 and 3 selected.

   if sy-tabix = 2 or sy-tabix = 3.

         lo_el_check->set_selected( abap_true ).

endif.

ENDLOOP.

hope this helps,

revert for further clarifications

Regards,

Kiran

0 Kudos

Hi Kiran!

You pointed in the right direction. The only additional stuff I had to do was go one level deeper and get the child, perhaps simply because of the way the context was modelled.

Appreciate your help and thank you once again.

Best,

Praveen

Answers (0)