on 2015 Oct 24 6:28 AM
Dear All,
I override the java script Date() method to override system date and time from server date and time. The date picker is defaulted with server date but the problem is the datepicker dialog is not opening.
Date = function (Date) {
MyDate.prototype = Date.prototype;
return MyDate;
function MyDate() {
return currentServerDate; //currentServerDate is my server date
}
}(Date);
I'm getting this below error,
Uncaught TypeError: Cannot read property 'apply' of undefined
(anonymous function) @ UniversalDate.js:6
c.init @ Calendar.js:6
E.extend.constructor @ sap-ui-core.js:152
M.extend.constructor @ sap-ui-core.js:152
E.extend.constructor @ sap-ui-core.js:152
f @ sap-ui-core.js:152
o @ sap-ui-core.js:143
_ @ DatePicker.js:6
b @ DatePicker.js:6
a.onclick @ DatePicker.js:6
a._callEventHandles @ sap-ui-core.js:152
a._handleEvent @ sap-ui-core.js:152
U._handleEvent @ sap-ui-core.js:152
p @ sap-ui-core.js:60
Q.event.dispatch @ sap-ui-core.js:71
v3.handle @ sap-ui-core.js:71
For working Date picker below .js are loading in network tab.
Calendar.js
CalendarUtils.js
Header.js
Month.js
MonthPicker.js
YearPicker.js
DateRange.js
CalendarRenderer.js
messagebundle_en_US.properties
HeaderRenderer.js
MonthRenderer.js
MonthPickerRenderer.js
But In this overriding case below .js are loading.
Calendar.js
CalendarUtils.js
Header.js
Month.js
MonthPicker.js
YearPicker.js
Please help me to resolve this.
Thanks,
Santhosh Gowda
Request clarification before answering.
Hello Santosh,
Would like to know the scenario, why do you want to display current date from server date ? Because if the client's date is 5 Nov and it’s going to highlight probably 4 or 6 which would be then a wrong indication for the client.
Anyways
Option 1 : Get rid of the current date border completely using css by overriding the main css class.
.sapUiCalDayToday>.sapUiCalDayNum { border: none !important; line-height: 2.6875rem; }
Your users will not be confused with current date border, and anyway you set the server date as default date.
Option 2 : Overriding the Date Picker method would not help, the highlight I guess comes from sap.ui.unified.calender.Month.js and it would not be simple to do it as the variable is set at many places using (new Date).
Option 3: Overriding CSS might can only be a temporary workaround as you rightly said should be your last option, but in my opinion too not a good clean way as also mention by others.
Regards,
Vasu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasu,
new Date() will gives system date.But in client system date is different so i took date from server.
For example: Create Sales Order - Document date by default with new Date()( assume system date is 07/11/2015) but as per server date (06/11/2015). That's way i'm setting server date.
But if i open date dialog- Purple color box is showing system date (i.e., 07/11/2015). As per my requirement it should be server date(06/11/2015).
Please correct me-JS Bin - Collaborative JavaScript Debugging
The 'today' date is determined in the sap.ui.unified.calendar.MonthRenderer class;
a helper object 'oHelper' is created with property 'oToday' which holds the current client date:
MonthRenderer.getDayHelper = function(oMonth, oDate){
var oHelper = {};
....
oHelper.oToday = CalendarUtils._createUniversalUTCDate(new Date());
....
return oHelper;
};
Upon iterating through the month days, a check is done to see if the day matches today, and then the border class is applied:
if (oDay.getUTCMonth() == oHelper.oToday.getMonth() && oDay.getUTCFullYear() == oHelper.oToday.getFullYear() && oDay.getUTCDate() == oHelper.oTo day.getDate()) {
oRm.addClass("sapUiCalDayToday");
mAccProps["label"] = oHelper.sToday + " ";
}
So I guess you somehow need to override the MonthRenderer.getDayHelper method, but not sure if this can be done easily
User | Count |
---|---|
78 | |
22 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.