on 08-16-2007 8:05 AM
Hi,
I have a context node structure :
Context1(0..n)
|_
Options1
Now the values for options are codes like 'EQ','NE','BT',etc which comes from the backend.I have to show the value in a UI element and also show the other possible values which the user can select using a drop down.
For this I guess I have to use a dropdownbyindex UI element,as there are multiple elements in the node.
I think I have to fill the values of the dropdown through some supply function
I checked out the example code given:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
method fillDropDown1 .
implicit available data objects
wd_Context type ref to if_wd_context_node.
wd_This type ref to if_DropDownByIdx.
data:
lt_attributes type standard table of if_dropdownbyidx=>element_dropdown1,
wa_attributes like line of lt_attributes,
lt_scarr type cl_wd_flight_model=>tt_scarr.
field-symbols:
<scarr> like line of lt_scarr.
cl_wd_flight_model=>get_scarr( importing et_scarr = lt_scarr ).
loop at lt_scarr assigning <scarr>.
wa_attributes-carrid = <scarr>-carrid.
insert wa_attributes into table lt_attributes.
endloop.
node->bind_elements( lt_attributes ).
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
So i guess this will fill my dropdown list,
but I also want to show the value that has come from the backend already selected in the input field.
Any ideas?
Thanks and Regards
Sourav
Hi ,
Thanks a lot for your help.This thing works but there is a small problem that I am facing.
As you said I ceated my context with cardinality (0..n) and then filled in the values and pre-selected the values I am getting from the backend by setting the correct lead selection.But see I have multiple values coming from the backend.Say for the first loop I have 'EQ',then I am setting the leadselection to point to the element having 'EQ',in the second loop I have 'BT',then I set the lead selection to point to the correct element.But that is also changing the value I set first.So my dropdown field hows both the values as 'BT',whereas it should have shown EQ for the first drop down and 'BT' for the second one.Also when I select from the list say EQ for dropdown 1 the value in dropdown 2 chnages automatically to EQ.
In my context node the properties have been set as follows:
Cardinality:0..n
Selection:0..1(tried chnaging to 0..n,doesn't work)
Initialization Lead Selection:False
Singleton:False
For the dropdown by index that I created the selection chnage behaviour is kept auto.
Any ideas where the problem lies?
Thanks and Best Regards
Sourav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sascha,
Actually I dont know during design time how many dropdown boxes I require.I am creating the dropdowns dynamically at runtime and mapping them to the context.Is there a way by which we can do this without the need to having to create separate context node for each drop down?
Best Regards
Sourav
Hi Sourav.
No there is no way. A context node represents the data for one dropdown in your case. And a dropdown changes the selection in this node. So how would you find out what the user ants to select if all dropdowns would be bound to this node.
I am afraid you have to create al the nodes dynamically too in this case.
Cheers,
Sascha
You can use a dropdown by key UI element, and bind the selectedKey property of each drop down to a different attribute. If the list of values in all the drop downs is going to be the same, you can populate them from a common valueset, which could be a class attribute in your view controller. Then you should do a set_attribute for each attribute, passing different values. So one value is selected in the first drop down and another is selected in the next and so on.
In this case too, you need different attributes for each drop down. If its drop down by index, you need different nodes. Each attribute has to be created dynamically if you do not know them at design time.
Regards,
Nithya
Hi Sourav,
For creating dropdownbyindex we need to have a node of cardinality 0..n / 1..n and we need to have a attribute for this context node.
We need to populate the values to the context, we can do this in WDDOINIT method (supply function is not needed).
For example: Define a node (for eq. 'TEXT') with cardinality '0..n' with attribute (for eq. 'TEXT').
In the view create a UI element DropDownIndx
Bind the text property of DropDownbyIndex UI element to attribute Text of context node Text.
For populating the values to the node text;
In the WDDOINIT method you can prepare an internal table with the values and bind it to the node and the lead selection defines the selected element.
The below code sample may help.
method WDDOINIT .
for populating the values in drop down
data:
node_text type ref to if_wd_context_node,
stru_text type if_componentcontroller=>element_text,
tab_text type if_componentcontroller=>elements_text .
node_text = wd_context->get_child_node( name = if_componentcontroller=>wdctx_text ).
Set/fill your values
stru_text-text = 'Value1'.
append stru_text to tab_text.
stru_text-text = 'Value2'.
append stru_text to tab_text.
set values to the node
call method node_ddi_also_text->bind_table
exporting
new_items = tab_text.
endmethod.
For reading the values which user has selected in dropdown:
for reading the selected index you can write the logic/method for the Onselect event of dropdownbyindex ui element. in the method read the attribute of the node text. the lead selection of the node gives the selected element (you can use the code wizard to read the context).
For setting the deafult value set the lead selection of the node to the desired elements index.
YOu can find more information about this UI element at:
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/dd/b0884118aa1709e10000000a155106/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/dd/b0884118aa1709e10000000a155106/content.htm</a>
Best regards,
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sourav.
So you want to do a preselection in the drop down?
You can do this in multiple ways.
Maybe the simplest would be to loop the internal table and the call bind
element for each wa of the table. If the current criteria match you can set the lead selection for this element:
loop at lt_scarr assigning <scarr>.
wa_attributes-carrid = <scarr>-carrid.
lr_element = node->bind_element(
new_item = wa_attributes
set_initial_elements = abap_false
).
if wa_attributes-carrid eq 'SOME_VALUE'
node->set_lead_selection( lr_element ).
endif.
endloop.
or do you want to do siomething else?
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.