cancel
Showing results for 
Search instead for 
Did you mean: 

Toggling action from static checkbox on dynamic checkboxes

Former Member
0 Kudos

Hi Experts,

In my application I have created On Checkbox named All statically.

Now I want that if this checkbox is marked as "checked" then the other two checkboxes named A1 and A2 which are created dynamically should be checked automatically. How to achieve this functionality?

Please help.

Thanks,

Pratibha

Edited by: pratibhas on Feb 18, 2010 6:27 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

When you must have created dynamic checkboxes you must have bound its Selected or Checked property to some attribute.

Try setting those attributes to abap_true when your ALL checkbox is checked.

Regards

Manas Dua

Former Member
0 Kudos

Hi ,

I have done like this :

SELECT * INTO TABLE it_dom FROM dd07t
     WHERE domname = 'ZREQTYPES'.

    LOOP AT it_dom INTO wa_dom.
      str1 = wa_dom-domvalue_l.
      str2 = wa_dom-ddtext.
      str = str1.
      CONCATENATE 'DYNAMIC.' str1 INTO str.

      lr_check = cl_wd_checkbox=>new_checkbox(
        text = str2
        bind_checked = str
        id = str1 ) .

      cl_wd_grid_data=>new_grid_data( EXPORTING element = lr_check ).

      lr_container->add_child( the_child = lr_check ).

    ENDLOOP.

Former Member
0 Kudos

Hi

as per your code you are binding it to context node DYNAMIC

and attribute name is same as value of str1.

So I would say that in your code just get a reference to this attribute and set it to true, u can use the same loop

only instead of new checkbox and other stuff, you need to get node reference and set its attribute value.

Or other way could be

As you know the dynamic check box Id - value of str1...

you can set a flag when ALL check box is clicked in your on check method

and then in domodifview based on this flag set you

can get the view element by Id - str1 and set the checkbox as checkbed by using metho Set_checked.

Regards

Manas Dua

Former Member
0 Kudos

Hi manas ,

I have added this code to set value.It is giving error " Acces Vai Null Object not possible

IF lo_componentcontroller->flag = 'Y'.


    CALL METHOD lr_check1->set_checked
      EXPORTING
        value = 'X'.
    .

*  lr_check1 = cl_wd_checkbox->set_checked(
*  value 'X' ).

  ENDIF.

Pls help

Thanks,

Pratibha

Former Member
0 Kudos

Hi,

You must be creating both the checkbox and writing this code in wddomodifyview, just be sure that you write this code after you have created those checkbox, and also see to it the ID of checkbox is correct to get the element reference.

You can also make a check to execute your code only when you get a reference to the checkbox created dynamically.

Former Member
0 Kudos

Hi Manas,

Please tell me how to get IDs...I am trying but each time it is either giving error o tnothing is happening...

Please help

Thanks,

Pratibha

Former Member
0 Kudos

Hi

As per your code, your Id's are stored in variable str1

SELECT * INTO TABLE it_dom FROM dd07t

WHERE domname = 'ZREQTYPES'.

LOOP AT it_dom INTO wa_dom.

str1 = wa_dom-domvalue_l.

str2 = wa_dom-ddtext.

str = str1.

So, you can again loop at it_dom and use value str1 ( wa_dom-domvalue_l ) as ID.

Former Member
0 Kudos

Hi,

I have written follwoing code for setting...Is it correct? My confusion is where to pass ID of checkboxes becoz set_checked has pnly one parameter...

IF lo_componentcontroller->flag = 'Y'.


    CALL METHOD lr_check1->set_checked
      EXPORTING
        value = 'X'.
  ENDIF.

Former Member
0 Kudos

Hi,

the ID will only come into use while getting the referene of check box in parameter lr_check1.

to get the reference into lr_check1

you have to write this code

lr_check1 ?= view->get_elemet( ID = str1 ).

Edited by: Manas Dua on Feb 19, 2010 1:11 PM

Former Member
0 Kudos

Hi MAnas,

I have written following code ..pls tell why I am getting " Access Via Null Object Not Possible "

.

METHOD wddomodifyview .

  DATA : lr_ui_root TYPE REF TO if_wd_view_element,
    lr_container TYPE REF TO cl_wd_uielement_container,
       lr_container_t TYPE REF TO cl_wd_uielement_container,
    lr_check TYPE REF TO cl_wd_checkbox,

 lr_check1 TYPE REF TO cl_wd_checkbox,
    it_dom TYPE STANDARD TABLE OF dd07t,
       lr_delegate_button TYPE REF TO cl_wd_button,
       lr_view_delegate TYPE REF TO cl_wd_button,
       wa_dom LIKE LINE OF it_dom.

  DATA:  lo_componentcontroller TYPE REF TO ig_componentcontroller.
  lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).

  DATA : str TYPE string,
     str1 TYPE string,
     str2 TYPE string.

  IF first_time = abap_true.

    lr_ui_root = view->get_element( 'TC2' ).
    lr_container ?= lr_ui_root.
endif.
*clear internal tables
    CLEAR: it_dom,
            wa_dom.
data : id1 type abap_bool.

*fill the requistion type drop down with person's id pre raised requisitions.
    SELECT * INTO TABLE it_dom FROM dd07t
     WHERE domname = 'ZREQTYPES'.

    LOOP AT it_dom INTO wa_dom.
      str1 = wa_dom-domvalue_l.
      str2 = wa_dom-ddtext.
      str = str1.
      CONCATENATE 'DYNAMIC.' str1 INTO str.

      lr_check = cl_wd_checkbox=>new_checkbox(
        text = str2
        bind_checked = str
        id = str1 ) .

      cl_wd_grid_data=>new_grid_data( EXPORTING element = lr_check ).

      lr_container->add_child( the_child = lr_check ).
  lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
      IF lo_componentcontroller->flag = 'Y'.

lr_check ?= view->get_element( ID = str1 ).

    CALL METHOD lr_check->set_checked
      EXPORTING
        value = 'X'
    .
  ENDIF.
    ENDLOOP.

*IF lo_componentcontroller->flag = 'Y'.
*
*
*    CALL METHOD lr_check1->set_checked
*      EXPORTING
*        value = 'X'.
*    .
*
**  lr_check1 = cl_wd_checkbox->set_checked(
**  value 'X' ).
*
*  ENDIF.


ENDMETHOD.

Thanks,

Pratibha

Former Member
0 Kudos

HI

can you tell me exactly at what line you are getting this error.

or can you paste some part of shortdump here

Former Member
0 Kudos

Hi,

I am getting error at this line :

lr_container->add_child( the_child = lr_check ).

And Error Is as under :::

Note

The following error text was processed in the system D11 : Access via 'NULL' object reference not possible.

The error occurred on the application server kcinhjsap12_D11_00 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: WDDOMODIFYVIEW of program /1BCWDY/7GCOK02YK0840142NIOZ==CP

Method: IF_WDR_VIEW_DELEGATE~WD_DO_MODIFY_VIEW of program /1BCWDY/7GCOK02YK0840142NIOZ==CP

Method: DO_MODIFY_VIEW of program CL_WDR_DELEGATING_VIEW========CP

Method: MODIFY_VIEW of program CL_WDR_VIEW===================CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Method: DO_MODIFY_VIEW of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW=================CP

Method: EXECUTE of program CL_WDR_MAIN_TASK==============CP

Method: IF_WDR_RUNTIME~EXECUTE of program CL_WDR_MAIN_TASK==============CP

Former Member
0 Kudos

Hi,

i tried your code to create a checkbox dynamically and it is working fine for me ( Instead of looping, i was just creating one checkbox with hardcode binding path and ID ).

As I noticed in the following piece of code

IF first_time = abap_true.

lr_ui_root = view->get_element( 'TC2' ).

lr_container ?= lr_ui_root.

endif.

you have endif statement.

So when modifyview is called second time then you dont have reference to lr_container.

probably that can be the cause.

and other could be 'TC2' is the right ID of Transparent Container ..

Just check on these

Former Member
0 Kudos

Hi Manas,

You are right. Now when I click on ALL check box remainig two are getting checked automatically, but when I uncheck ALL checkbox, the remaining are not getting unchecked instead I am getting Error : There is already element with ID OTH_TRL which is ID of my first checkbox which I am getting from str.

Please help,

Thanks,

Pratibha

Former Member
0 Kudos

This is because on any action domodifyview will be triggered and you will be creating those check box with same ID again.

Place you code inside some if else loop so that check box are created only once .

On uncheck of ALL - you have to again do the same codig to but with abap_false for method set_enabled.

Former Member
0 Kudos

Hi,

Where to write code for uncheck of all.Because there is single event for checkbox i.e. "On_toggle"

Former Member
0 Kudos

Hi

Set a flag in the event on_toggle as true or false and use that flag in domodifyview to check or unckeck other check box.

More than that I would say figure it out yourself, just play with the application, work on the logic and you will get it right ....

Answers (0)