Search code examples
datepickersapui5

Weird error using DatePicker, Calendar Constructor fails?


I am working on a SAPUI5 application at my company (so I cannot post much example) and I am having problems using the DatePicker. I have defined it in the XML in a normal way (see below) using the sap.m namespace. It all works well in the development server. The problem is when it is transported to the testing server the popup calendar causes an error (see below) to occur. This error does not occur in the development server ever. To be specific, the cause of the error is the button next to the input field that lets you pick from a mini-calendar.

A strange event I noticed is that if I open the mini-calendar in a different view it'll work in the view where I am having problems.

If anyone has seen something similar to this or knows anything that could help me solve this problem, please let me know. The error all comes from built-in libraries and not from my written code.

The XML file

<DatePicker id="blah blah" width="70%" value="blah blah"
            editable="blah blah" 
            valueFormat="YYYY-MM-dd" change="ValidateDate" />

The error in the console:

MonthRenderer.js:6 Uncaught TypeError: m.getLegend is not a function
    at Object.M.getDayHelper (MonthRenderer.js:6)
    at Object.M.renderDays (MonthRenderer.js:6)
    at Object.M.renderMonth (MonthRenderer.js:6)
    at Object.M.render (MonthRenderer.js:6)
    at constructor.R.renderControl (sap-ui-core.js:1089)
    at I.renderControl (sap-ui-core.js:457)
    at Object.C.render (CalendarRenderer.js:6)
    at constructor.R.renderControl (sap-ui-core.js:1089)
    at constructor.R.render (sap-ui-core.js:1093)
    at I.render (sap-ui-core.js:457)

EDIT:

See @Developer post below. It appears that when the library calls the Calendar constructor, it does not include a getLegend() method. On his post below, you can see that his function is defined but when I do the same thing on my test server the function comes up as undefined. How is this possible???


Solution

  • I've found the line where the getLegend() function is created, you may want to investigate the constructor for the Calendar class.

    enter image description here