Sometimes binding can end up quite involved - in this case I think coding directly is actually easier.
To do this, set up a dropdown with the following static data:
1 Last 24 hours
3 Last 3 days
7 Last 7 daysThen attach the following code to the dropdown’s propertyChange event:
if event.propertyName == 'selectedValue' and event.newValue > -1:
days = event.newValue
endDate = system.date.now()
startDate = system.date.addDays(endDate, -days)
dateRange = event.source.parent.getComponent('Date Range')
dateRange.startDate = startDate
dateRange.endDate = endDate
This code checks to make sure the user has selected a valid entry from the list before calculating the start and end times and writing them directly to the date range control.
I’ve attached a project to show how this is done. Just right-click on the Windows entry in the Project Browser and select import to try this out.