JQCalendar -- Alpha Anywhere V3 fix for new JavaScript date type : A5Customsolutions

JQCalendar -- Alpha Anywhere V3 fix for new JavaScript date type

by Jim Coltz on 10/18/14

AA V3 has changed the UX control behavior for date and date-time controls so that they are now JavaScript date objects instead of strings. This causes a calculated field to fail in the UX editing template that is provided with the calendar. You will only see this failure is you actually edit one of the date controls, or do a "recalculate all controls" from the UX menu.

The fix is to change the calculated field expression property of the UX for both the "StartDateTime" and "EndDateTime" controls to allow for the "StartDate" and "EndDate" controls to be JavaScript date objects.

I created a new JavaScript function that is universal for Alpha Five V11 - 12.3 that will treat the date controls as strings, or date objects depending on how A5 defines them. The code is as follows and can be placed in the JavaScript functions area of the UX:

[code]
function fixTimeFormat(parm,timeToFormat){
    //assumes both the startdate and enddate time pickers are set up the same.
    if(typeof(timeToFormat) == 'object'){    
        var unknownDateFormat;
        if (parm == "start"){
            unknownDateFormat = {dialog.object}.fieldHelpers.STARTDATE.dateTime.format; //get the date/time format for this date picker
            return timeToFormat.toFormat(unknownDateFormat);
        }
        if (parm == "end"){
            unknownDateFormat = {dialog.object}.fieldHelpers.ENDDATE.dateTime.format; //get the date/time format for this date picker
            return timeToFormat.toFormat(unknownDateFormat);
        }
        
    }else{
        return timeToFormat;
    }
}
[/code] 

Then, in the "StartDateTime" and "EndDateTime" controls, replace the existing calculated field expression with this code, replacing the start with end where appropriate:
[code]
//for StartDateTime control
fixTimeFormat('start',StartDate) + ' ' + StartTime 
[/code]
[code]
//for EndDateTime control
fixTimeFormat('end',EndDate) + ' ' + EndTime 
[/code]
 

Comments (0)


Leave a comment


Alpha Custom Database Solutions, LLC
Committed to the pursuit of excellence in quality, service and value.