Search code examples
smartclient

ComboBoxItem not clearing unknown value on blur


To Start, here is my ComboBoxItem field

{
    name: "State",
    type: "ComboBoxItem",
    canEdit: true,
    valueMap: {
        WI: "Wisconsin",
        IL: "Illinois",
        MN: "Minnesota",
        MI: "Michigan"
    },
    addUnknownValues: false,
    allowEmptyValue: false,
    completeOnTab: true
}

I'm getting very different behavior out of a ComboBoxItem when it is in a ListGrid vs when it's in a DynamicForm.

In a DynamicForm if you were to type in a value that does NOT have a match in the valueMap and then leave the field, it would return to the previous value.

In an editable ListGrid if you were to type in a value that does NOT have a match in the valueMap and then leave the field, it would keep what ever characters you typed and try to save the edits with that string.

Walkthrough

The code used in the walkthrough

isc.VLayout.create({
    height: 500,
    width: 900,
    margin: 100,
    members: [
        isc.ListGrid.create({
            height: "100%",
            width: "100%",
            canEdit: true,
            modalEditing: true,
            extraSpace: 5,
            fields: [
                { name: "Name", canEdit: true, },
                {
                    name: "State",
                    type: "ComboBoxItem",
                    canEdit: true,
                    valueMap: {
                        WI: "Wisconsin",
                        IL: "Illinois",
                        MN: "Minnesota",
                        MI: "Michigan"
                    },
                    addUnknownValues: false,
                    //allowEmptyValue: false,
                    completeOnTab: true
                }
            ],
            data: [
                { Name: "Evan", State: "WI" },
                { Name: "Erik", State: "IL" },
                { Name: "Philip", State: "MI" },
            ]
        }),
        isc.DynamicForm.create({
            height: "100%",
            width: "100%",
            border: "1px solid #ababab",
            canEdit: true,
            fields: [
                { name: "Name", canEdit: true, },
                {
                    name: "State",
                    type: "ComboBoxItem",
                    canEdit: true,
                    valueMap: {
                        WI: "Wisconsin",
                        IL: "Illinois",
                        MN: "Minnesota",
                        MI: "Michigan"
                    },
                    addUnknownValues: false,
                    allowEmptyValue: false,
                    completeOnTab: true
                }
            ],
            values: { Name: "Evan", State: "WI" }
        })
    ]
});

Solution

  • It would appear that addUnknownValues has a different effect on the two instances.

    I solved the issue by moving addUnknownValues to the ListGridField's editorProperties

    this is the updated ListGridField item

    {
        name: "State",
        type: "ComboBoxItem",
        canEdit: true,
        valueMap: {
            WI: "Wisconsin",
            IL: "Illinois",
            MN: "Minnesota",
            MI: "Michigan"
        },
        editorProperties:{
            addUnknownValues: false,
            allowEmptyValue: false,
            completeOnTab: true
        }
    }