0

Is there any way to change the order of autocomplete when using list in apex:inputText?

The variable specified in list uses LIST<String> to store the characters.

Apex---------

List<String> SelectList = new List<String>();
SelectList.add('c');
SelectList.add('a');
SelectList.add('b');

Visualforce------

<apex:inputText value="{!xxxx}" list="{!SelectList}" id="area"/>

result---------

a
b
c

Ideal------

c
a
b

1 Answer 1

0

Unfortunately, it appears that this can't be fixed. While the browser honors the datalist in the order specified, it appears that Visualforce converts the values to a Set, which ends up getting sorted lexicographically, probably because of the Critical Update from Summer '15 that introduced iteration stability in unordered collections, so the datalist is rendered in ascending order. If you want to fix this, you'd have to use a <input>/<datalist> manually, then use some JavaScript to bind to a hidden variable to send to the server, if that's your intent. See the link above for how to write a datalist yourself manually.

1
  • I appreciate your cooperation,It was very helpful.
    – yuta
    Commented Jul 14, 2021 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .