What steps will reproduce the problem?
1. Create a SelectItem
2. Setup a LinkedHashMap where the keys as "3", "2", and "1"
3. Invoke selectItem.setValueMap (valueMap);
What is the expected output? What do you see instead?
I expect the order of the SelectItem values to be "3", then "2", then "1".
Instead, I get values in order "1", then "2", then "3".
It seems that SelectItem sorts the contents ignoring the LinkedHashMap order.
When I setup the same SelecItem with values "c", then "b", then "a", the order is respected.
So this could be a problem only when the keys are "numbers"...
What version of the product are you using? On what operating system?
SmartGWT 2.4
GWT 2.1.1
Windows 7
What browser(s) does this happen in? Are there any browsers where the
issue does not occur?
Happens in IE 9
Do not know if this works fine in other browsers...
Please provide any additional information below.
1. Create a SelectItem
2. Setup a LinkedHashMap where the keys as "3", "2", and "1"
3. Invoke selectItem.setValueMap (valueMap);
What is the expected output? What do you see instead?
I expect the order of the SelectItem values to be "3", then "2", then "1".
Instead, I get values in order "1", then "2", then "3".
It seems that SelectItem sorts the contents ignoring the LinkedHashMap order.
When I setup the same SelecItem with values "c", then "b", then "a", the order is respected.
So this could be a problem only when the keys are "numbers"...
What version of the product are you using? On what operating system?
SmartGWT 2.4
GWT 2.1.1
Windows 7
What browser(s) does this happen in? Are there any browsers where the
issue does not occur?
Happens in IE 9
Do not know if this works fine in other browsers...
Please provide any additional information below.
Code:
import java.util.LinkedHashMap;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.layout.HLayout;
public class TestSelectItemOrdering implements EntryPoint {
public void onModuleLoad () {
// add a SelectItem with data sorted in order c/b/a
// this SelectItem properly respects the LinkedHashMap order c, b, a
final SelectItem selectItem1 = new SelectItem ();
selectItem1.setTitle ("SelectItem with alpha keys c/b/a");
{
final LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String> ();
valueMap.put ("c", "Option C");
valueMap.put ("b", "Option B");
valueMap.put ("a", "Option A");
selectItem1.setValueMap (valueMap);
selectItem1.setValue ("b");
}
// add a SelectItem with data sorted in order 3/2/1
// this SelectItem inproperly renders the LinkedHashMap order as 1, 2, 3
final SelectItem selectItem2 = new SelectItem ();
selectItem2.setTitle ("SelectItem with int keys 3/2/1");
{
final LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String> ();
valueMap.put ("3", "Option 3");
valueMap.put ("2", "Option 2");
valueMap.put ("1", "Option 1");
selectItem2.setValueMap (valueMap);
selectItem2.setValue ("2");
}
// add to a form
final DynamicForm form = new DynamicForm ();
form.setWrapItemTitles (false);
form.setFields (selectItem1, selectItem2);
// display
final HLayout mainLayout = new HLayout ();
mainLayout.setWidth100 ();
mainLayout.setHeight100 ();
mainLayout.addMember (form);
mainLayout.draw ();
}
}
Comment