Is there a way to restrict the date choices in DateTime input component in perspective to not allow to select future dates, only dates till the current date should be allowed to select on the calendar and the future dates should be grayed-out/disabled.
I put this in a change script on the value property of the DateTimePicker. It doesn’t gray out future dates, but it does disallow choosing dates in the future. You can tweak it to behave exactly how you want it to.
now = system.date.now()
if system.date.isAfter(currentValue.value,now) and origin!='Script':
try:
if system.date.isAfter(previousValue.value,now):
self.props.value = now
else:
self.props.value = previousValue.value
except AttributeError:
self.props.value = now
Both Date Picker components have a minDate and a maxDate property to define available dates for the picker. It doesn’t truly “gray-out” the unavailable dates, but it does prevent them from being selected and it applies a “restricted” cursor when hovering over restricted dates. Months and years in the dropdown ARE grayed-out.
There's no need for a script, Anders. A binding will do it with less overhead and can update constantly. In addition, your script seems to update maxDate after the user has chosen the date.
Create an Expression Binding on maxDate: now(5000)
This will update every 5 s.