Date Range component - lock outer range dates

Hi,

Is it possible to lock the outer range dates for the date range/easy chart component so user cannot go outside of set date range?

We want to limit what data user has access to. For example if they view data by ID number we want to lock the date range to specific date and times.

Ken

I don’t think there is a built in function for this. What I’ve done in the past is set up a property change script on the date selector, such that , if one of the dates goes outside the limits, set that date equal to the respective limit… In my experience, this is an effective solution.

1 Like

Appreciate the reply

I figured as much and that was one of the ideas that was floating around.

Thanks

Can i have an example of this? my tag tag seems to always get hung up by java.util.date and im not sure why

Hi DwSoFt,

Sorry for the late reply. Here is a basic example for a script that would go into Property Change Scripts on a Date Range component:

if event.propertyName == "startDate":
	if event.source.startDate < system.date.getDate(2018, 00, 01):
		event.source.startDate = system.date.getDate(2018, 00, 01)
if event.propertyName == "endDate":
	if event.source.endDate > system.date.now():
		event.source.endDate = system.date.now()

Not sure if you were doing it, but in general I avoid using java.util.stuff, and try to stick to the ignition equivalents if possible… so system.date rather than java.util.date.

Hope this helps!

1 Like

FWIW, I always do exactly the opposite. The java.util.Date and java.util.Calendar stuff have been there since the beginning of Ignition and always work. You never know when you’ll want to cut and paste into an older install.

Interesting pturmel, I hadn’t thought of it that way, but that makes sense. Maybe I’ll expand my scripting vocabulary a little in future projects.