cancel
Showing results for 
Search instead for 
Did you mean: 

Problem wth setting defaut value for the Drop Down

srinivas_m2
Participant
0 Kudos

Hi EP Guys,

I am using the follwing method to create a dropdown, please tell me how to default particualr value of several options in the dropdown.

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf("values");

IModifiableSimpleValueSet values=myType.getSVServices().getModifiableSimpleValueSet();

values.put("account number 1","account name 1");
values.put("account number 2","account name 2");

in the above example i would like to ser account name 2 as my default value for the drop down.

Pls Help.

Thanks,

=======

Srinivas M.

Accepted Solutions (1)

Accepted Solutions (1)

former_member193726
Active Participant
0 Kudos

Hi Srinivas,

Try this... 100% helps. I tried your issue with DropdownByKey and DropDownByIndex. For DropDownByKey my earlier solution works.

But as you are using DropDownByIndex this should work!!!

Create a value node "vnSample" and a value attribute "vaSampleatt" under that node. In the property of the node set the cardinality of value node to 1..n and Selection to 1..1

Bind that attribute to your DropdownbyIndex.

Now in the implementation give the code below.

IPrivateSampleView.IVnSampleElement ele=wdContext.nodeVnSample().createVnSampleElement();

ele.setVaSampleAtt("Select Option 1");

wdContext.nodeVnSample().addElement(ele);

IPrivateSampleView.IVnSampleElement ele1=wdContext.nodeVnSample().createVnSampleElement();

ele1.setVaSampleAtt("Select Option 2");

wdContext.nodeVnSample().addElement(ele1);

//Loop for the number of values in the model node and create elements for the value node "vnSample" and set values to "vaSampleAtt".

After setting the values set the leadselection of the 0.

wdContext.nodeVnSample().setLeadSelection(1);

Hope this helps.

Regards,

Rekha Malavathu

Answers (5)

Answers (5)

srinivas_m2
Participant
0 Kudos

Hi..

Actullay i have seens SAP help ealier but it has taken Node Attribute and and Value attibute inside it.. but i has only attributw which is of type (Dictionary Simple Type) may be this method doesn't support the leadselection option.. as it has no Node at all\.

So now i am chaging the code as given SAP Help.

Thnks for your replies..

Srinivas...

Former Member
0 Kudos

Hi,

DDIndex Example

http://help.sap.com/saphelp_nw04/helpdata/en/95/93fe1e71a2e44691b1f041e67f71aa/frameset.htm

DDKey Example

http://help.sap.com/saphelp_nw04/helpdata/en/74/450e8af57065468e88e4b86de47e4b/frameset.htm

Go thru this links you can find your information what u require.

do you have any more problems post your issues.

Thanks,

Lohi.

former_member193726
Active Participant
0 Kudos

Hi Srinivas,

Please let me know if its dropdownByKey or dropdownbyIndex.

Regards,

Rekha Malavathu

srinivas_m2
Participant
0 Kudos

Hi All,

Thanks for tour replies..

<b>Rekha:</b> I tried the solution u suggested infact it's clearing all the set values and in the dropdown it shows only one value, i.e. which we set in the last..

i.e. wdContext.currentContextElement().setValues("account number 2");

<b>Kanwalpreet & Prabakar :</b>

Surpisingly i am not getting the method "setLeadselection" is not there under "wdContext.currentContextElement()"

wdContext.currentContextElement().setLeadSelection(2);

i tried to hard code and facing error that "The method is not defined"

Any other alternative?

Thanks,

Srinivas M...

Former Member
0 Kudos

Try usin dis

if(firstTime){

IWDDropDownByKey ddkey = (IWDDropDownByKey)view.getElement("DropDownByKey");

ddkey.setSelectedKey("2");

}

Former Member
0 Kudos

Hi Srinivas,

When you say currentElement(), you are pointing to the leadselected element. There you cannot set lead selection. you can set leadselection only to a node, it may be context node, or any other.

such as,

wdContext.setLeadSelection(1);

wdContext.nodePerson().setLeadSelection(1);

Note:

-> LeadSelection is like a pointer. It points to only one element of a node at run time.

-> The index of the elements of any node starts from '0'.

-> If you dont want any element to be lead selected, set the LeadSelection to '-1'.

Prabhakar.

former_member193726
Active Participant
0 Kudos

Hi Srinivas,

Try this code.

ISimpleTypeModifiable myType=wdThis.wdGetAPI().getContext().getModifiableTypeOf("values");

IModifiableSimpleValueSet values=myType.getSVServices().getModifiableSimpleValueSet();

values.put("account number 1","account name 1");

values.put("account number 2","account name 2");

wdContext.currentContextElement().setValues("account number 2");

Regards,

Rekha Malavathu

Former Member
0 Kudos

wdContext.currentContextElement().setLeadSelection(2);

Message was edited by:

Kanwalpreet singh

Former Member
0 Kudos

Hi,

setLeadSelection() will take only integer type as its parameter. So give the index number of the element as parameter for <i>setLeadSelection(),</i> which you want to be selected by default.

regards,

Prabhakar.