cancel
Showing results for 
Search instead for 
Did you mean: 

Sort a dropdown list

Former Member
0 Kudos

Hi,

Can anybody help with the following question. I need to dynamically sort a listbox? Anybody any ideas?

Cheers,

Onno

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

try the below code

wdContext.nodeMainNode().sortElements( new Comparator(){

public int compare( Object o1, Object o2 ){

int i = 0;

IPrivateRFCAppView.IMainNodeElement e1 = ((IPrivateRFCAppView.IMainNodeElement)o1);

IPrivateRFCAppView.IMainNodeElement e2 = ((IPrivateRFCAppView.IMainNodeElement)o2);

i = e1.getVar1().compareToIgnoreCase( e2.getVar1() );

return i;

}//compare

});

please check the below thread

AM

Answers (2)

Answers (2)

Former Member
0 Kudos

Great thanks for the quick. Replies.

Cheers,

Onno

luciano_leitedasilva
Contributor
0 Kudos

Hi Onno,

Using the class IModifiableSimpleValueSet you have a standard method to sort the dropdow content.

IModifiableSimpleValueSet valueSet = wdThis.wdGet<Component Controller>().wdGetContext().getContext().getModifiableTypeOf("node.attribute").getSVServices().getModifiableSimpleValueSet();

<b>valueSet.sort(boolean sortByKey, boolean up, boolean ignoreCase);</b>

I give you two examples:

First: Sort by text value:

<b>valueSet.sort(false, true, true);</b>

Second: Sort by Key:

<b>valueSet.sort(true, true, true);</b>

Regards,

Luciano