Skip to Content
author's profile photo Former Member
Former Member

Odata, XML, DateTimeInput & Databinding

Hi all,

sorry if it is written somewhere but i did not manage to find an accurate information about my issue.

i am trying to bind an DateTimeInput to a value named LicenceDate, which is a Date in my oDataModel.

<DateTimeInput id="inputLicenceDate" type="Date" placeholder="Enter driver's licence date"
                                                value="{LicenceDate}"  
                                                displayFormat='dd/MM/yyyy'
                                                />

when displaying it throws an error :

2014-06-05 16:37:25 Format Error: value property Mon May 01 2000 00:00:00 GMT+0200 (Romance Standard Time) does not match with valueFormat dd/MM/y of Element sap.m.DateTimeInput#driverFormPage--inputLicenceDate -


I have already tried

<DateTimeInput id="inputLicenceDate" type="Date" placeholder="Enter driver's licence date"
                                                dateValue="{LicenceDate}"  
                                                displayFormat='dd/MM/yyyy'
                                                />

But it throws an error without displaying anything :

Error: Type Error: Expected JavaScript Date Object for property dateValue of Element sap.m.DateTimeInput#driverFormPage--inputLicenceDate

But, when i display the model in the console it says that the bound data is an Date Object :

LicenceDate : Date {Mon May 01 2000 00:00:00 GMT+0200 (Romance Standard Time)}

Can somebody show me the way?

Regards,

Marc

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 10, 2014 at 09:49 AM

    hi,

    i founda solution.

    view.xml:

    <DateTimeInput id="inputLicenceDate" type="Date"  placeholder="Enter driver's licence date"
                                                value="{path:'LicenceDate',
                                                        formatter: '.formatDate'}" displayFormat="dd/MM/yyyy"
                                                    />
    
    
    
    
    

    controller.js:

    
     
     
    fo

    rmatDate: function(aValue){

    if(aValue){

    jQuery.sap.require("sap.ui.core.format.DateFormat");

    var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "dd/MM/yyyy"});

    return oDateFormat.format(aValue);

    }

    },

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 10, 2014 at 08:25 AM

    Hi,

    i would also like to know what are the valids valueFormat. I did not manage to find it into documentation.


    Regards,

    Marc

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2014 at 09:39 AM

    hi,

    i read some threads talking about this but none with XML views.

    Still no answer to help me?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Chandrashekhar Mahajan

      Hi,

      thanks for your help but i would like to have a snippet using databinding.

      When looking in the ODataModel ( http://localhost:8080/myService/MyODataSample.svc/Drivers(3) ) : this date is <d:LicenceDate>2014-09-05T22:00:00</d:LicenceDate>

      Whereas in the app, the error message shows it as : Sat Sep 06 2014 00:00:00 GMT+0200 (Romance Standard Time)


      I would like to build my xml view as fellow :

      <DateTimeInput id="inputLicenceDate" type="Date" placeholder="Enter driver's licence date"
                                                      value="{LicenceDate}"  valueFormat=????"                                                 />
      
      
      


      I tried some valueFormat but "yyyy-mm-ddTHH:MM:ss.ms GMTZ" and others do not work.


      Regards,

      Marc

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.