Announcement

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

    Issue with FormItem.visibleWhen and boolean criteria and boolean valueMap

    Hi Isomorphic,

    please see this modified sample (v12.1p_2022-11-30):
    As you can see, the testcase works for one DynamicForm (showing different FormItems on selection of the RadioGroupItem), but does not in the other (not showing any further FormItems on selection of the RadioGroupItem, unexpected).
    The reason is the different valueMap in the broken one, I think.

    Best regards
    Blama

    Code:
    var brokenValueMap = {
        true: "Yes",
        false: "No"
    }
    
    var workingValueMap = {
        "yes": "Yes",
        "no": "No"
    }
    
    isc.DynamicForm.create({
        ID: "broken",
        groupTitle: "Broken",
        width: 300,
        fields: [{
                name: "onOrder",
                type: "radioGroup",
                title: "Shipment on order",
                redrawOnChange: true,
                width: 50,
                valueMap: brokenValueMap
            },
            {
                name: "orderDate",
                type: "date",
                wrapTitle: false,
                title: "Order Placed",
                visibleWhen: {
                    _constructor: "AdvancedCriteria",
                    operator: "equals",
                    fieldName: "onOrder",
                    value: true
                }
            },
            {
                name: "orderDate2",
                type: "date",
                wrapTitle: false,
                title: "Order Placed2",
                visibleWhen: {
                    _constructor: "AdvancedCriteria",
                    operator: "equals",
                    fieldName: "onOrder",
                    value: false
                }
            }, {
                name: "btn",
                title: "Show values",
                type: "ButtonItem",
                click: "isc.say(form.getValues())"
            }
        ]
    });
    
    isc.DynamicForm.create({
        ID: "working",
        groupTitle: "Working",
        width: 300,
        fields: [{
                name: "onOrder",
                type: "radioGroup",
                title: "Shipment on order",
                redrawOnChange: true,
                width: 50,
                valueMap: workingValueMap
            },
            {
                name: "orderDate",
                type: "date",
                wrapTitle: false,
                title: "Order Placed",
                visibleWhen: {
                    _constructor: "AdvancedCriteria",
                    operator: "equals",
                    fieldName: "onOrder",
                    value: "yes"
                }
            }, {
                name: "orderDate2",
                type: "date",
                wrapTitle: false,
                title: "Order Placed2",
                visibleWhen: {
                    _constructor: "AdvancedCriteria",
                    operator: "equals",
                    fieldName: "onOrder",
                    value: "no"
                }
            },
            {
                name: "btn",
                title: "Show values",
                type: "ButtonItem",
                click: "isc.say(form.getValues())"
            }
        ]
    });
    
    isc.VLayout.create({
        members: [broken, working]
    });

    #2
    Not a bug, but a detail of how JavaScript works. Unlike Java Maps, where the key can be multiple types, JavaScript property names are always Strings. This:

    Code:
    var brokenValueMap = { true: "Yes", false: "No" }
    .. is exactly the same as this:

    Code:
    var brokenValueMap = { "true": "Yes", "false": "No" }
    So your criteria is comparing actual boolean false to the string "false", and those are not equal.

    Comment


      #3
      Hi Isomorphic,

      thank you for the fast answer. That of course explains it.

      Best regards
      Blama

      Comment

      Working...
      X