# Can I aply a Map Transfrom to a table with binded Named Query in Ignition Perspective

**URL:** <https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 7, 2024, 10:09am UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006 "2024-05-07T10:09:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 7, 2024, 10:09am UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/1 "2024-05-07T10:09:27Z")

</div>

I´m trying to change the color on some cells using map transform in Tag Binding.  
I wonder if I can do this and also add a dataset.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/d/7d099dff3371faf65c0f86339a6c4af09c7a9c86.png)

---

<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:** [May 7, 2024, 10:32am UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/2 "2024-05-07T10:32:28Z")

</div>

The [Map Transform | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/working-with-perspective-components/bindings-in-perspective/transforms/map-transform) takes one value and transforms it into something else. It doesn't work on datasets.

For table styling see the examples:

> **[Styling Rows Based on Values | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table/styling-rows)**
>
> This page includes examples detailing different ways to style rows based on values using Script Transforms. Each example accomplishes similiar results through different binding and data types to change the background color of a row or individual...

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 7, 2024, 10:35am UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/3 "2024-05-07T10:35:20Z")

</div>

Thanks Transistor.

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [May 7, 2024, 12:31pm UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/4 "2024-05-07T12:31:58Z")

</div>

All of that is true but you can also do things in script transforms that have nothing to do with the binding. It can make for a confusing design so take that into consideration.

The original binding is the thing that drives the chain of transforms. So in this case your transform is returning a color to the property you are bound on when the value of the tag changes.

If you add a script transform after that and let the last line be to return value (what was passed in) it will run that script and still return the color to the property that has the binding on this. You can do whatever you want in that script transform including loading data into another property that takes a data table.

Note that this entire chain of events will be kicked off when the tag you are bound to receives a value.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 7, 2024, 1:02pm UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/5 "2024-05-07T13:02:36Z")

</div>

Do you think would be a good idea to aply a event script onEditCellStart?, something like:

```python
def runAction(self, event):

    color_map = {
        "1": "#C53D20",
        "2": "#C1DB10",
        "3": "#a9c520",
        "4": "#ffa794"
    }
    return color_map.get(value, "")  

color = getColor(self.view.params.rowData)

```

this one doesn´t work, but I guess there is a way to make it work.

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [May 7, 2024, 1:30pm UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/6 "2024-05-07T13:30:39Z")

</div>

I'm a little confused about what you're trying to accomplish.

The map transform will change the color of an element based on a binding. It sounds like you might be trying to color the cell that's being edited based on some conditional stuff that comes from a tag.

If you're just trying to dynamically bind the cell that's being edited based on some tag value you can do a binding on selection\style\classes.

The steps look something like this:

1. Create a style class for each row style you want to apply.
2. Apply a binding on the "classes" property I mentioned above and points to the tag that you want to control the appearance with.
3. Then add a map transform to it and change the "output type" on the right side of the map transform to "Style Class"
4. Map each value to a style

This will make the selected row style itself dynamically based on the value of your specified tag. Note that you also have to make sure the "enableRowSelection" property is enabled on the table.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [May 7, 2024, 2:03pm UTC](https://forum.inductiveautomation.com/t/can-i-aply-a-map-transfrom-to-a-table-with-binded-named-query-in-ignition-perspective/90006/7 "2024-05-07T14:03:13Z")

</div>

Thanks Steve, will try.
