cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting in dropdownbykey

Former Member
0 Kudos

Hi,

I've manage to manually added list of values using svs in a for loop into a dropdown. Is there a way the list in the dropdown display in a sorted way?

Thanks

Edited by: Shreya Eknath on Apr 23, 2009 12:38 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

from where ur adding values to the dropdown?

while adding the values perform sorting and then add .

Regards,

Ramani.

Former Member
0 Kudos

Hi Ramani,

Below are the codes on how I added the values to the dropdown. Please advice how to get the list display sorted alphabetically.

* IPrivateBsb.IBttlNode bttlNd =*

* wdContext.nodeBttl();*

* IWDAttributeInfo bttlList =*

* wdContext.getNodeInfo().getAttribute("BttlDrop");*

* ISimpleTypeModifiable bttlType =*

* bttlList.getModifiableSimpleType();*

* IModifiableSimpleValueSet valueSetBttl =*

* bttlType*

* .getSVServices()*

* .getModifiableSimpleValueSet();*

* for (int count = 0; count < bttlNd.size(); count++) {*

* IPrivateBsb.IBttlElement bttlEmt =*

* bttlNd.getBttllementAt(count);*

* valueSetBttl.put(*

* bttlEmt.getBttlId()*

* bttlEmt.getBttlName());*

* }*

pravesh_verma
Active Contributor
0 Kudos

Hi,

Try this code:


IPrivateBsb.IBttlNode bttlNd =wdContext.nodeBttl();
	   IWDAttributeInfo bttlList =wdContext.getNodeInfo().getAttribute("BttlDrop");
	   ISimpleTypeModifiable bttlType = bttlList.getModifiableSimpleType();
	   IModifiableSimpleValueSet valueSetBttl =bttlType.getSVServices().getModifiableSimpleValueSet();
	   List tempList  = new ArrayList();
	   for (int count = 0; count < bttlNd.size(); count++) {
		   IPrivateBsb.IBttlElement bttlEmt = bttlNd.getBttllementAt(count);
		   tempList.add(bttlEmt.getBttlName());
		}
	  
	   Collections.sort(tempList);
                    // Also check these ways.....
	    // Case-insensitive sort
                    // Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
                     
                    // Reverse-order sort
                    //    Collections.sort(list, Collections.reverseOrder());

	   int size = tempList.size();
	   String name = null;
	   for (int i = 0; i < size; i++) {
		name = (String)tempList.get(i);
		IPrivateBsb.IBttlElement bttlEmt = bttlNd.getBttllementAt(count);
		if(name.equalsIgnoreCase(bttlEmt.getBttlName())){
			valueSetBttl.put(bttlEmt.getBttlId(), name);

		}

I hope this helps.. Please revert back in case u want further help.

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi,

first get that node values in List.and then sort and add that List back to that node.

List list = new ArrayList();

for(int i=0;i<wdContext.nodeNew().size();i++)

{

String s=wdContext.nodeNew().getNewElementAt(i).getAttr();

list.add(i,s);

}

Collections.sort(list);

IPrivateFirstapplicationView.INewElement ele;

for(int i=0;i<list.size();i++)

{

ele=wdContext.createNewElement();

ele.setAttr(list.get(i).toString());

wdContext.nodeNew().addElement(ele);

}

and add these node values to ur dropdown.hope this will work fine please let me knw if there r any issues.

Answers (0)