# DateRange component events

**URL:** <https://forum.inductiveautomation.com/t/daterange-component-events/4416>\
**Category:** Archived Topics\
**Created:** [May 4, 2012, 2:10pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416 "2012-05-04T14:10:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [May 4, 2012, 2:10pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/1 "2012-05-04T14:10:31Z")

</div>

Hi!  
I need to fire event when I move DateRange component slider.  
I was trying to do that with MouseReleased event, but it does not work on slider himself.  
It works on every other place of DateRange component around that slider, but not on slider.  
How is it possible to fire MouseReleased event on DateRange slider?

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 4, 2012, 4:26pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/2 "2012-05-04T16:26:17Z")

</div>

You don’t use the mouseReleased event but rather the propertyChange event. It fires anytime a property on that component changes. So for the date range you can do this:`if event.propertyName in ["startDate", "endDate"]:
    # do your code here .....`

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [May 7, 2012, 6:08am UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/3 "2012-05-07T06:08:23Z")

</div>

Thank you.

Now I have such problem, that if I change DateRange component endTime and startTime, sometimes my code behind DateRange component event handler runs two times.  
I change endTime and startTime like this:

```auto
event.source.parent.getComponent('Date Range').endDate = newEndDate
event.source.parent.getComponent('Date Range').startDate = newStartDate
```

And it seems that event fires on every date change, first time on endDate change and second time on startDate change.  
Is it possible to change endDate and startDate at once, at the same time?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 7, 2012, 3:33pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/4 "2012-05-07T15:33:31Z")

</div>

No, you will get two property changes. However, you can run your script in an invokeLater function which will happen after both values update.

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [May 9, 2012, 5:08am UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/5 "2012-05-09T05:08:33Z")

</div>

Thing is that I am changing DateRange times from several places, not only by dragging slider. But I also want to drag it and fire my event behind that also. I have a time change panel, where I control endTime and startTiime of DateRange component and also dragging a slider possibility. This DateRange component controls my ClassicChart datasets by refreshing queries. And now those queries run double. Are you having plans to add Event Handler to DateRange slider itself as well?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 9, 2012, 3:17pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/6 "2012-05-09T15:17:06Z")

</div>

I understand. We don’t have any plans right now to fix that. You can add a button to the window that they can click on to refresh the data.

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [May 14, 2012, 2:19pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/7 "2012-05-14T14:19:03Z")

</div>

Ok, I made multiple queries run behind button using system.db.runQuery(“query”) for every dataset in Classic Chart and using invokeAsynchronous, to run them all at once in separate threads.  
Now I am not able to indicate datasets loading using Chart propertiesLoading, because query excecutes in system function and Chart datasets filling runs so fast, that I don’t even see it. I putted indicator visibility to 1 behind RunQueries button, but I don’t know how to turn visibility off, because I don’t know how to get when Chart datasets finish loading.  
Could you help me somehow with that?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 14, 2012, 3:34pm UTC](https://forum.inductiveautomation.com/t/daterange-component-events/4416/8 "2012-05-14T15:34:45Z")

</div>

Sure, you can put a progress bar or image on the screen that shows it is loading. In your script you can show/hide the progress bar like this:[code]def doAsynch(event=event):  
import fpmi

```
def doLater(event=event):
    event.source.parent.getComponent("Progress Bar").visible = 1
fpmi.util.invokeLater(doLater)

....... # your code

def doLater(event=event):
    event.source.parent.getComponent("Progress Bar").visible = 0
fpmi.util.invokeLater(doLater)

```

fpmi.util.invokeAsynchronous(doAsynch)[/code]You have to use a invokeLater to change any properties on the screen.
