# Is there an event I can use in a change script for when a user sorts a table?

**URL:** <https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [October 20, 2023, 7:06pm UTC](https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784 "2023-10-20T19:06:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [October 20, 2023, 7:06pm UTC](https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784/1 "2023-10-20T19:06:45Z")

</div>

I have a Perspective table with a defined column and the sortable property set to true.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/2/92f0f2e45b100aeecab4f009adf44ed9d0d58338.png)

When the user selects the table to sort to ascending or descending is there some event I can look out for to trigger a custom script?

As far as I can tell the answer is no but thought I'd ask anyways.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 20, 2023, 7:09pm UTC](https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784/2 "2023-10-20T19:09:24Z")

</div>

I don't think so, but what problem are you trying to solve?

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [October 20, 2023, 7:35pm UTC](https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784/3 "2023-10-20T19:35:47Z")

</div>

I had originally asked the question in this thread:

> [@\[SOLVED\] Add alternating color to Perspective table rows through scripting after sorting the data](https://forum.inductiveautomation.com/t/solved-add-alternating-color-to-perspective-table-rows-through-scripting-after-sorting-the-data/73649):
>
> I have a generic Perspective table with an added custom property called ds that will call a named query in the future. On the table is a single system event onStartup that calls a custom method script on the table. [image] That custom method completes the following code: def colorRows(self): value = self.custom.ds # Initialize variables new\_list = [] is\_light = False # This variable will keep track of the current row color # Iterate over each dictionary in the original li…

but never got a clear answer on whether there was an event triggered by sorting a table.

I suppose what I am trying to do is style rows in a table **before CSS** sheets were introduced (v8.1.21).

I can do this using the striped color even / odd properties when there is a single color however when I want to color some rows red and others green based off data criteria that doesn't work anymore.

I think I can use the markdown component to inject html but I haven't convinced myself that is worth my time yet so I am looking for a quicker way to solve the problem 🙂

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 20, 2023, 7:42pm UTC](https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784/4 "2023-10-20T19:42:52Z")

</div>

I suggest that you be much more discrete and put a colored icon on each row to indicate good and bad and let the table apply the alternate banding. A simple view rendering in one column would do the trick.

I would also make sure that it is clear to someone with red-green color-blindness by either changing the icon or changing the shape (circle good, square bad). It will make the application appear much more professional and be a lot easier on the eye. (Your sample screengrab isn't either to me - but what do I know?)

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [October 20, 2023, 7:44pm UTC](https://forum.inductiveautomation.com/t/is-there-an-event-i-can-use-in-a-change-script-for-when-a-user-sorts-a-table/80784/5 "2023-10-20T19:44:32Z")

</div>

My hands are [metaphorically] tied by the customer on this one.

I am constrained to pre-css sheets and specific user colors.
