Besides the built-in validation process, developers are allowed to implement custom
validation process to meet the requirements in their applications. The custom validation
process can be implemented in OnValidateDisabledTime client-side
event. The event should return boolean value to determine the result of the custom
validation process, which will be used in rendering and data operation process.
In this topic, you will learn how to implement custom disabled time validation.
To implement custom disabled time validation
- Bind WebScheduler
to Access database.
- Using OnValidateDisabledTime client-side event, place the following
code:
function OnValidateDisabledTime(controlId, startTime, endTime, resourceID, elementType)
{
var s = ISGetObject(controlId);
var globalDisabledTime = s.DisabledTime;
var resource = s.GetResourceById(resourceID);
var loopLength = 1;
var resourceDisabledTime;
if (s.ViewSettings.SelectedViewMode == "Timeline")
{
loopLength = 2;
resourceDisabledTime = resource.DisabledTime;
}
var result = false;
for (var i = 0; i < loopLength; i++)
{
var disabledTimeCollection;
if (i == 0)
disabledTimeCollection = globalDisabledTime;
else if (i == 1)
disabledTimeCollection = resourceDisabledTime;
for (var j = 0; j < disabledTimeCollection.length; j++)
{
result = ValidateDisabledTime(s, startTime, endTime, disabledTimeCollection[i], elementType);
if (result)
return result;
}
}
return result;
}
function ValidateDisabledTime(s, startTime, endTime, disabledTime, elementType)
{
var result = false;
var dtInfoStartTime = disabledTime.StartTime;
var dtInfoEndTime = disabledTime.EndTime;
var viewSettings = s.ViewSettings;
var viewMode = viewSettings.SelectedViewMode;
var timelineMode = viewSettings.SelectedTimelineViewMode;
if (endTime.getTime() <= dtInfoEndTime.getTime())
{
if (startTime.getTime() >= dtInfoStartTime.getTime())
{
if (elementType == "Event" && endTime.getTime() >= dtInfoEndTime.getTime())
result = false;
else
result = true;
}
else
{
if (startTime.getTime() < dtInfoStartTime.getTime())
{
if (elementtype == "Cell" && endTime.getTime() > dtInfoStartTime.getTime())
result = true;
else if (elementType == "Event" && endTime.getTime() >= dtInfoStartTime.getTime())
result = true;
}
}
}
else if (endTime.getTime() > dtInfoEndTime.getTime() && dtInfoEndTime.getTime() > startTime.getTime() &&
endTime.getTime() > dtInfoStartTime.getTime())
result = true;
return result;
}
|
|
The OnValidateDisabledTime() function should return boolean value
to indicate the result of DisabledTime validation. Return true,
if the event's dateTime in DisabledTime range. Return false, if
the event's dateTime is not in DisabledTime range.
|