cancel
Showing results for 
Search instead for 
Did you mean: 

assigning values dynamically to drop down

Former Member
0 Kudos

Hi,

I have drop down for which i have to assign values dynamically, I am getting values as a form of Array list.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Refer this code to populate data in drop down by index at runtime


String color[] = {"Red", "Green","Blue" };
    IPrivatePrototypeView.IPaintElement elt ;
    
    for(int i=0; i<color.length; i++){
    	elt = wdContext.createPaintElement();
    	elt.setColor(color<i>);
    	wdContext.nodePaint().addElement(elt);	
    }

Mandeep Virk

Answers (3)

Answers (3)

PradeepBondla
Active Contributor
0 Kudos

Hi,

do you want to use drop down by key or drop down by index?

If drop down by key, use above code by siva.

If you want to use drop down by index, populate the value attribute with you array list data.

bind the drop down by index's "texts" property to this value attibute.

PradeeP

Former Member
0 Kudos

Hi,

You can go for dropdownbyindex ui element too and copy your values in the arraylist to the context node binded to the texts property of the dropdownbyindex.

Regards,

Murtuza

former_member197348
Active Contributor
0 Kudos

Hi Venki,

Say your ArrayList is al . Create a value attribute under the root node. Say test. Bind this test to the DropdownByKey UI element. You can populate test attribute like this.

IWDAttributeInfo attributeInfo = 
wdContext.getNodeInfo().getAttribute(IPrivate<viewname>View.IContextElement.TEST);

ISimpleTypeModifiable valuesType = 
attributeInfo.getModifiableSimpleType();
 
IModifiableSimpleValueSet VS= 
valuesType.getSVServices().getModifiableSimpleValueSet();
 	
 	  for (int i = 0; i < al.size(); i++) {
		VS.put(al.get(i),""+al.get(i));
	}

Regards

Siva