Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Strange order of numeric options in SelectItem

    If I amend the example at http://www.smartclient.com/#selectItem to have the following numeric options then they display
    in the order 10-16,00-09 when I "Try It"...

    Code:
    isc.DynamicForm.create({
        width: 500,
        fields: [{
            name: "shipTo", title: "Ship to", type: "select",
            valueMap: {
    "00":"00",
    "01":"01",
    "02":"02",
    "03":"03",
    "04":"04",
    "05":"05",
    "06":"06",
    "07":"07",
    "08":"08",
    "09":"09",
    "10":"10",
    "11":"11",
    "12":"12",
    "13":"13",
    "14":"14",
    "15":"15",
    "16":"16"
            }
        }]
    });
    This happens in IE 11, FF 24.0 and Chrome 32.

    Is there any way to get them displaying 00-16?

    Thanks,

    Dan

    #2
    This is because JavaScript Objects have a very surprising property of being order preserving for all keys except those that happen to be parsable as integers.

    The workaround is to either use optionDataSource instead, or avoid numeric keys that need to appear in non-numeric order.

    See this thread for more background.

    Comment

    Working...
    X