cancel
Showing results for 
Search instead for 
Did you mean: 

Input Fields need to get displayed dynamically

Former Member
0 Kudos

I have a Drop Down for the month and a Pushbutton.

Say Ex: i have selected September and clicked the button. Now below that 30 input fileds need to get displayed as the number of days in september is 30. Similayly for February 28 fields should get displayed.

How can achieve this ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

which part is your problem? populating the list and fetching value from it or the dynamic addition of inputfields.

if you already have the list value and now want to add the 30 input fields then it goes as below in the wddomodifyview method

you will have to add labels along with inputfields as a label is required with an inputfield...also you need to make sure that the IDs of each of the labels and Inputfields are different so as to avoid duplication of ui element names on the view.

get selected value from the list.

case 'JAN'.

lv_counter = 31.

case 'FEB'.

lv_counter = 28. "or 29 as the case may be.

..

..

..

case 'DEC'.

lv_counter = 31.

endcase.

**get root containter reference.

DATA : lr_container TYPE REF TO cl_wd_uielement_container,

lr_inputfield type ref to cl_wd_input_field,

lr_label type ref to cl_wd_label.

data : lv_id type string,

lv_label_id type string

lv_temp_num(2) type n.

lv_temp_num = lv_counter.

concatenate 'INPUT' lv_temp_num into lv_id.

concatenate 'LABEL' lv_temp_num into lv_label_id.

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

do lv_counter times.

lr_label = cl_wd_label=>new_label( id = lv_label_id text = lv_temp_num ).

CALL METHOD lr_container->add_child

EXPORTING

the_child = lr_label.

lr_inputfield = cl_wd_input_field=>new_input_field( id = lv_id length = 10 ).

CALL METHOD lr_label->set_label_for( lv_id ).

CALL METHOD lr_container->add_child

EXPORTING

the_child = lr_inputfield.

enddo.

hope it helps....

Former Member
0 Kudos

Hi Jain,

I have to display the input fields based on the month(Drop down box).If it is February 28 input fields shoud get displayed. If is is september, 30 input fields should get displayed.

Here are some of my doubts,

1. How to design the Layout - Shall we go for Matrix Layout ? or ....

2. How many context elements do we need to create ?

Former Member
0 Kudos

Hi Priyank,

Can you explain me about the following statement that you have pasted in the previous post.

lr_label = cl_wd_label=>new_label( id = lv_label_id text = lv_temp_num ).

Former Member
0 Kudos

For that statement that i have posted earlier, i am getting an error in the browser.

The error is

View Element with ID D1 in View FIRST Already Exists

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Personally I wouldn't use dynamic coding in WDDOMODIFYVIEW at all. Instead I would use the MultiPane or RowRepeater to acomplish this. Either of these UI elements allows a variable number of inner UI elements based upon the binding to a context node. That way when the value of your drop down changes, you only have to adjust the internal table that is bound to the source context of the MultiPane or RowRepeater.

Former Member
0 Kudos

Hi Jung ,

Thanks for your valuable reply. I have another doubt.

I have created the context node with 31 input fileds and also in layout i have bounded these.

in wdmodify view, based on the following lines of code i have made the input fields invisible.

lr_inputfield ?= view->get_element( 'D1' ).

lr_inputfield->set_visible( '01' ).

Up to now it is OK. Now if i click on the pushbutton, i need to re-modify these input fileds. for that i need to write the code at the event on the button. But in the Button method i dont have the scope for view. Please suggest me the solution.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I don't understand why you are still using the WDDOMODIFYVIEW. Why are you setting input fields invisible? Why are you creating 31 inputfields in your context node? I don't think you understand what I mean by using the MultiPane or RowRepeater. The number of context elements controls how many UI elements get output. You don't need to set any fixed numbers at design time.

Former Member
0 Kudos

Hi Jung,

I really dont know about the Multipane & Row Repeater. PLease clarify these and relate to my requirement.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Why don't you start by reading the online help for the UI elements that I suggested. They will do what I described already - allow for the output of a variable number of UI elements based upon the number of context elements within the node they are bound to.

Answers (0)