cancel
Showing results for 
Search instead for 
Did you mean: 

calling text dynamically based on check box

Former Member
0 Kudos

Hi Team

In webdynpro there is a requirement to display text dynamically based on check box. For example we have 4 check boxes, when a user checks 'US'. then text 'This is US' should be displayed. If User unchecks and checks 'India' then US Text should be refreshed and text should be 'This is india'.

actual requirement is like Loop at screen in module pool programming.How we can show this in webdynpro.

Request you to help me on this one.

Thanks and Regards,

Shakeer Hussain

Accepted Solutions (0)

Answers (3)

Answers (3)

GirieshM
Active Contributor
0 Kudos

Hi Shakeer,

Both Bansal and Rama are correct but I need to clarify whether you need only one entry to be selected at a time or more than one. If only one entry then you should use the radio button instead of checkbox or if more than one entries then you should assign 4 textviews in the node and dislay it in the layout. The scenario in the way if i select both US and IN then both the text will be displayed in their respective textviews.

With Regards,

Giriesh M

nishantbansal91
Active Contributor
0 Kudos

Hi Giriesh,

There are multiple possible cases for that. If you want to create one text view for all the box it is also possible and you can also restrict the user to check only one check box at one time.

But if you have requirement to check only one check box at one time then i would suggest use the Radio button instead of checkbox & Define one Text view for all radio button,

Regards,

Nishant Bansal

ramakrishnappa
Active Contributor
0 Kudos

Hi,

You can achieve your requirement as below

  •      Create a node DATA with 5 attributes
    • check1, check2,check3 & check 4 of type WDY_BOOLEAN
    • DISPLAY_TEXT of type string

  • Create 4 check boxes in view layout and bind the property CHECKED to context attributes check1, check2, check3, check4
  • Create a text view ui element and bind the property TEXT to context attribute DISPLAY_TEXT
  • Create an event ON_CHECK and assign to action ONTOGGLE

    

  • You can read the context DATA and based on your check box event, you can set the text to DISPLAY_TEXT attribute

          Sample code:


lo_el_data->get_static_attributes(
    IMPORTING
      static_attributes = ls_data ).

  CASE id.
    WHEN 'CHECK1'.
      CLEAR: ls_data-check2,
             ls_data-check3,
             ls_data-check4.
      ls_data-display_text = 'USA'.
    WHEN 'CHECK2'.
      CLEAR: ls_data-check1,
             ls_data-check3,
             ls_data-check4.
      ls_data-display_text = 'INDIA'.
    WHEN 'CHECK3'.
      CLEAR: ls_data-check1,
             ls_data-check2,
             ls_data-check4.
      ls_data-display_text = 'check3'.
    WHEN 'CHECK4'.
      CLEAR: ls_data-check1,
             ls_data-check2,
             ls_data-check3.
      ls_data-display_text = 'check4'.
    WHEN OTHERS.
  ENDCASE.

  lo_el_data->set_static_attributes(
    EXPORTING
      static_attributes = ls_data ).

Hope this helps you.

Regards,

Rama

nishantbansal91
Active Contributor
0 Kudos

HI Shakeer Hussain,

Define one Text View along with Check Box .

Create one Context Element of String Type and Bind to TEXT View 'Text' Property.


Please Check  Event of Check Box ONToogle.

This Event is generated when Clicking on Checkbox, Define one Method as a Event Handler & set the Text View Attribute Property as per your selection.

Let me know if any issue.

Regards.

Nishant Bansal