Announcement

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

    visibleWhen and datetime FormItem

    SmartClient Version: SNAPSHOT_v12.1d_2019-09-10/AllModules Development Only (built 2019-09-10)

    Chrome on OSX

    Hello, please try this test case:

    Code:
    isc.VLayout.create({
        members: [
            isc.DynamicForm.create({
                ID: "form1",
                numCols: 4,
                width: 650,
                fields: [
                    {
                        name: "date1", title: "Date1", type: "datetime", useTextField: true, wrapTitle: false
                    }
                ]
            }),
            isc.DynamicForm.create({
                ID: "form2",
                numCols: 4,
                width: 650,
                fields: [
                    {
                        name: "date2", title: "Date2", type: "datetime", useTextField: true, wrapTitle: false
                    }
                ]
            }),
            isc.Label.create({
                contents: "visible when Date 1 is greaterOrEqual than Date2",
                wrap: false,
                visibleWhen: {
                    _constructor: "AdvancedCriteria",
                    operator: "and",
                    criteria: [
                        {fieldName: "form1.values.date1", operator: "greaterOrEqualField", value: "form2.values.date2"}
                    ]
                }
            })
        ]
    })
    The label is visible when date1 is greater or equal to date2.

    This works unless you choose two datetime values with the same date, but where the time part of date2 is greater that the time part of date1.

    So, it seems that the time part is ignored in the criteria.

    #2
    Thanks for the test case. This issue has been fixed back to 12.0 available in builds starting on Sep 11.

    Comment


      #3

      SmartClient Version: SNAPSHOT_v12.1d_2019-09-12/AllModules Development Only (built 2019-09-12)

      I can confirm it's fixed, thank you very much.

      Comment


        #4
        SmartClient Version: SNAPSHOT_v12.1d_2019-10-01/AllModules Development Only (built 2019-10-01)

        Chrome on OSX

        Hello, here's another variation of the test case, where the time part is ignored in the criteria:

        Code:
        isc.VLayout.create({
            ID: "layout1",
            members: [
                isc.DynamicForm.create({
                    ID: "form1",
                    numCols: 4,
                    width: 650,
                    fields: [
                        {
                            name: "date1", title: "Date1", type: "datetime", useTextField: true, wrapTitle: false,
                            changed: function (form, item, value) {
                                layout1.provideRuleContext("layout1.date1", value);
                            }
                        }
                    ]
                }),
                isc.DynamicForm.create({
                    ID: "form2",
                    numCols: 4,
                    width: 650,
                    fields: [
                        {
                            name: "date2", title: "Date2", type: "datetime", useTextField: true, wrapTitle: false,
                            changed: function (form, item, value) {
                                layout1.provideRuleContext("layout1.date2", value);
                            }
                        }
                    ]
                }),
                isc.Label.create({
                    contents: "visible when Date 1 is greaterOrEqual than Date2",
                    wrap: false,
                    visibleWhen: {
                        _constructor: "AdvancedCriteria",
                        operator: "and",
                        criteria: [
                            {fieldName: "layout1.date1", operator: "greaterOrEqualField", value: "layout1.date2"}
                        ]
                    }
                })
            ]
        });
        If I use
        date1: 10/01/2019 15:12
        date2: 10/01/2019 15:13

        the Label remains visible.
        If the date part of date2 is greater, then the Label is hidden.

        Comment


          #5
          Because you are supplying the date values to ruleContext directly there is no matching field definition to determine the correct date type. By default only the logical date is compared.

          Comment


            #6
            Thanks, so it's by design.

            And that default behaviour isn't modifiable with some override?

            Actually I find it a bit misleading, as I thought (and didn't see nothing against in the docs) that if I need a compare of only the date (or time) part, I could use DateUtil.createLogicalDate (or createLogicalTime) to create the dates.

            Comment


              #7
              Correct. It is by design. See https://www.smartclient.com/smartcli...e.compareDates for details on the date comparison performed as part of matching criteria.

              Comment

              Working...
              X