# Binding tags and expressions to table cells

**URL:** <https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [October 16, 2023, 9:40pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555 "2023-10-16T21:40:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 16, 2023, 9:40pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/1 "2023-10-16T21:40:11Z")

</div>

So when I add data to a table in the designer I can get the data looking fine, at least on the properties panel. I exported the table to see what the json would look like so I can dynamically create this table. I have another table generated in a similar way, but with static data. For the life of me this doesn't work with tags. The cells just have the json in them.

```auto
data={"Unit":{"value":unitn}
,"Driver":{"value":""}
,"Location":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"[default]"+unit+"/Location"},"type":"tag"}}
,"Status":{"binding":{"config":{"expression":"runScript(\"Faults.GetLabel\",0,tag(\"[default]\"+unit+\"/StatusIndicator\"),tag(\"[default]\"+unit+\"/Status\"))","type":"expr"}}}
,"Suc PSI":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/SuctionPressure\""},"type":"tag"}}
,"1st PSI":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/FirstStagePressure\""},"type":"tag"}}
,"2nd PSI":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/SecondStagePressure\""},"type":"tag"}}
,"3rd PSI":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/ThirdStagePressure\""},"type":"tag"}}
,"4th PSI":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/FourthStagePressure\""},"type":"tag"}}
,"Final PSI":{"binding":{"config":{"fallbackDelay":2.5,"mode": "expression","tagPath":"\"[default]\"+unit+\"/\"+tag(\"[default]\"+unit+\"/InterfaceDischargePressure\")+\"Pressure\""},"type":"tag"}}
,"RPMs":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/MotorRPMs\""},"type":"tag"}}
,"VFD Hz":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/VFDFrequency\""},"type":"tag"}}
,"VFD Amps":{"binding":{"config":{"fallbackDelay":2.5,"mode":"direct","tagPath":"\"[default]\"+unit+\"/VFDAmps\""},"type":"tag"}}
,"FMLA":{"value":""}
,"%LA":{"value":""}
,"Last Poll":{"binding":{"config":{"expression":"timeStampOf(\"[default]\"+unit+\"/Status\")","type":"expr"}}}
,"MaxBHP":{"value":""}
,"Frame":{"value":""}
,"County":{"value":""}
,"State":{"value":""}
,"Latitude":{"value":""}
,"Longitude":{"value":""}}
ds.append(data)
unitList.props.data = ds

```

Any thoughts on getting this working correctly?Thx,jake

---

<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 16, 2023, 9:50pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/2 "2023-10-16T21:50:40Z")

</div>

Table JSON should look like this:

```auto
[
  {
    "city": "Helsinki",
    "country": "Finland",
    "population": 635591
  },
  {
    "city": "Jakarta",
    "country": "Indonesia",
    "population": 10187595
  },
  {
    "city": "Madrid",
    "country": "Spain",
    "population": 3233527
  }
]

```

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 16, 2023, 9:52pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/3 "2023-10-16T21:52:45Z")

</div>

I don't want the static values, but ones based on tags, and later some of the cells will use db queries.Thx,jake

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 16, 2023, 10:20pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/4 "2023-10-16T22:20:48Z")

</div>

> [@codersmurf](#):
>
> don't want the static values, but ones based on tags

Doesn't matter. @Transistor is showing you the shape **you** have to produce in that `.data` property. Which usually means a transform that mixes static and dynamic data together, yielding **a list of dictionaries**.

Give us more detail on what you really have for dynamic data and we can provide more guidance.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 17, 2023, 6:25am UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/5 "2023-10-17T06:25:25Z")

</div>

The above code is what's being used. So the first value is static and it shows correct, along with all the placeholder static values. Any of the bindings to expressions and tags and tag expressions from above just show the json output instead of what the json should generate.Thx,jake

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 17, 2023, 12:08pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/6 "2023-10-17T12:08:48Z")

</div>

You cannot put bindings in there. That's something you can only do in the designer, not at runtime.

---

<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 17, 2023, 1:01pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/7 "2023-10-17T13:01:20Z")

</div>

You'll need to do something like this pseudo-code:

```auto
tagPaths = ["[default]" + unit + "/Location", 
            "[default]" + unit + "/StatusIndicator",
            "[default]" + unit + "/SuctionPressure"
]
tagData = system.tag.readBlocking(tagPaths)
outputData = [
  {
    "city": "Helsinki",
    "country": "Finland",
    "population": tagData[0].value
  },
  {
    "city": "Jakarta",
    "country": "Indonesia",
    "population": tagData[1].value
  },
  {
    "city": "Madrid",
    "country": "Spain",
    "population": tagData[2].value
  }
]

```

[/quote]

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 17, 2023, 2:41pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/8 "2023-10-17T14:41:10Z")

</div>

Ah, gotcha. I was hoping at runtime I could generate the json to display in the table. I'll just do what I did before and generate the static values and fill the table with a button.Thanks all

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 17, 2023, 2:46pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/9 "2023-10-17T14:46:07Z")

</div>

Why a button ? Bindings are cool.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 17, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/10 "2023-10-17T14:47:23Z")

</div>

Agreed, but I was told bindings don't work on the tables if I try and generate them in code. Do you know of a way to make this work?Thx,jake

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 17, 2023, 2:51pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/11 "2023-10-17T14:51:59Z")

</div>

If you are trying to get live tag values into a table, and the list of tags varies, you might find my [tags() expression function](https://www.automation-pros.com/toolkit/doc/utility.html#tags) helpful. (Note the plural.)

You would certainly want to combine with one or more of my iteration functions to build your runtime JSON.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 17, 2023, 2:56pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/12 "2023-10-17T14:56:29Z")

</div>

So the code above that I showed works when I put it in the data, kind of. It shows correct in the property pane. I exported it to get the format. But for some reason when I set the data prop to the genereated dictionary it shows the json and not what the json should produce.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 17, 2023, 3:53pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/13 "2023-10-17T15:53:56Z")

</div>

You can't generate bindings. But you can generate the data that those bindings would have generated.  
You're overcomplicating things:  
You're trying to generate bindings on rows, that would then generate the row data. Don't even try.  
Instead, generate the whole data, once and for all, from a transform on the top level binding.

Let's take an example.  
Say, you have 2 tags, and you want your table to have 2 rows, one for each tag.  
What you're trying to do, if I understood correctly, is to generate tag bindings for each of these 2 rows.  
Instead, on the table's data property, add a structure binding on these 2 tags.  
Then, format the acquired data in a transform so that it corresponds to the format the table expects.

Now, this is a simplistic example. But we don't know what kind of data you're dealing with, so it's hard to be more accurate without being exhaustive, and no one has time for that.  
This is why you were asked to give us more details about your data sources.

> [@pturmel](#):
>
> Give us more detail on what you really have for dynamic data and we can provide more guidance.

Also, I suggest taking a few steps back and telling us what your end goal is, so we can help you find a solution to an issue, instead of finding a fix to a flawed solution.

> **[The XY Problem](https://xyproblem.info/)**
>
> Asking about your attempted solution rather than your actual problem

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 17, 2023, 4:04pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/14 "2023-10-17T16:04:16Z")

</div>

> [@codersmurf](#):
>
> But for some reason when I set the data prop to the genereated dictionary it shows the json and not what the json should produce

You are mixing up the idea of **configuration** JSON, which the designer produces in project files and exports, and **values** JSON, which Perspective uses to drive the display of components.

Bindings are **configuration**. Assigning to properties via scripting (or the **output** of other bindings) is **values** JSON, never configuration JSON.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 17, 2023, 4:19pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/15 "2023-10-17T16:19:10Z")

</div>

So we have a bunch of units, that change all the time. They have data such as pressures and such. One customer wants a table format rather than our usual gauges and such. So when the view opens it will find units assigned to the customer and build a table with the tags attached to those units. It sounds like I just need to do what I do on the unit list view that works similarly, except it's all static and I have a button that nukes and regenerates the data on it.Thx,jake

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 17, 2023, 4:26pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/16 "2023-10-17T16:26:17Z")

</div>

Make a custom property that lists the tags that need to be displayed in your table.  
Then bind the table's `data` property to that list, and use `system.tag.readBlocking` in a script transform to read them. Then format them to match what a table expects: a list of dicts, and return that list.

---

<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 17, 2023, 4:54pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/17 "2023-10-17T16:54:51Z")

</div>

> [@codersmurf](#):
>
> One customer wants a table format rather than our usual gauges and such.

Then create a "table" using a **[flex repeater](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Flex+Repeater)**.

- Create a single-row view that takes parameter Description, Value and Units.
- Add three labels to the view. Bind Description and Unit's props.text to the relevant parameters. Create a tag binding on the Value props.text and point that to the parameter.

Now on the main view

- Add the flex repeater.
- Set the viewpath to your single-row view.
- Add an instance of the flex repeater for each row required and set their parameters.

You can add headers, etc., to make it look like a table.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 17, 2023, 5:25pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/18 "2023-10-17T17:25:32Z")

</div>

I can't say I see the advantage of this over a regular table...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 17, 2023, 6:10pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/19 "2023-10-17T18:10:41Z")

</div>

> [@pascal.fragnoud](#):
>
> the advantage of this

Concur. A regular table with a column view that converts a tagpath into an indirectly bound value runs rings around a flex repeater.

---

<div class="post-metadata">

**Author:** ![codersmurf](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@codersmurf](https://forum.inductiveautomation.com/u/codersmurf)\
**Post date:** [October 17, 2023, 6:34pm UTC](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555/20 "2023-10-17T18:34:01Z")

</div>

Agreed, but it appears the tables don't support this. Can we get someone at inductive to see about fixing this issue?

[Next page](https://forum.inductiveautomation.com/t/binding-tags-and-expressions-to-table-cells/80555.md?page=2)
