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

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

The Map Transform | Ignition User Manual takes one value and transforms it into something else. It doesn't work on datasets.

For table styling see the examples:

1 Like

Thanks Transistor.

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.

1 Like

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

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.

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.

1 Like

Thanks Steve, will try.