openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Binding OData to sap.m.DatePicker does not work for 31.12.9999

Open sloewhite opened this issue 11 years ago • 8 comments

I found this strange behaviour of the DatePicker while consuming our OData service:

Service returns something like this:

ValidFrom: "/Date(1285891200000)/" (1.10.2010)
ValidTo: "/Date(253402214400000)/" (31.12.9999)

Then the datepickers are initialized like this

<DatePicker dateValue="{model>ValidFrom}" />
<DatePicker dateValue="{model>ValidTo}" />

Which then looks like this

image

Opening the Diagnostics reveals that the dateValue is somehow not set

image

Manually setting it to that date does work btw

picker.setDateValue(new Date(253402214400000));

sloewhite avatar Oct 15 '15 10:10 sloewhite

What is the UI5 version your are using? Did you try to test this with the latest version?

matz3 avatar Oct 15 '15 12:10 matz3

We are embedding the latest stable version directly from the CDN.

https://sapui5.netweaver.ondemand.com/sdk/sap-ui-core.js

Yes, thats SapUI5 and not OpenUI5, but it's working with neither, I also tested it with

https://openui5beta.netweaver.ondemand.com/resources/sap-ui-core.js

sloewhite avatar Oct 16 '15 07:10 sloewhite

Thanks. I will have a look into it.

matz3 avatar Oct 16 '15 07:10 matz3

@mschleeweiss I'm sorry, I did not have a deeper look into this, yet.

To be able to reproduce this issue some more information would be really helpful:

  • How is the ODataModel initialized? sap.ui.model.odata.ODataModel or sap.ui.model.odata.v2.ODataModel? Configuration options?
  • A plain service response of the bound entity (just the two fields)

A running example where this can be reproduced would really speed up processing this issue (even without a real OData Service as backend).

matz3 avatar Nov 06 '15 08:11 matz3

I did some debugging, hope that helps.

image

Line 204: Problematic function Line 205: if clause is falsy (thats OK, since current dateValue should be null) Line 208: if clause is falsy (thats OK, since o is a valid date.. btw maybe switch first and second if clause?) Line 211: if clause is truthy (thats bad.... since oMaxDate is defined as Fri Dec 31 9999 00:00:00 GTM+0100) Line 217: Even though its invalid, date gets formatted Line 222: if clause is falsy, since DOM element is not yet rendered/available.

Thats why manually setting the date (picker.setDateValue(new Date(253402214400000));) works: The element is already rendered, so the value will be updated in line 225).

I am not sure why it works like that. An invalid date is displayed (if dom exists), but not stored in the underlying property. Imo the date should be neither displayed nor stored if it's invalid.

Anyway.. suggested solution: Increase maxDate by a few hours.

Concerning your other question: We are doing this in our manifest.json..

"dataSources": {
    "entitiesRemote": {
        "uri": "https://host:1234/sap/opu/odata/SAP/whatever/",
        "type": "OData",
        "settings": {
            "odataVersion": "2.0"
        }
    }
}

sloewhite avatar Nov 12 '15 12:11 sloewhite

Thanks! We will have a look into it. Int. reference 1580225795

matz3 avatar Nov 12 '15 13:11 matz3

@mschleeweiss we could finally fix this issue. It will be part of 1.36.1 and 1.34.4. Those versions are not officially released as stable versions, yet. But you should be able to test this fix as soon as the next 1.34 patch is released via the openui5beta deployment.

matz3 avatar Jan 26 '16 09:01 matz3

Looks like this will be the first 1.34 stable release, then, some time after February 10th.

akudev avatar Jan 26 '16 09:01 akudev