# Two Tables Question Using Text Fields

**URL:** <https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485>\
**Category:** General Discussion\
**Created:** [September 26, 2022, 4:15pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485 "2022-09-26T16:15:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [September 26, 2022, 4:15pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/1 "2022-09-26T16:15:36Z")

</div>

Good morning Team,

I have two tables that hold the same information but for different cranes, 1 and 2.

There are 14 fields in each table. Most all I have pointed at Table, but I would like to have the ability to select a row from either Cooler Crane 1 Info or Cooler Crane 2 Info and have the corresponding information show in the correct text field.

I have an example below where I pointed one text field to the first table but I need it to be dynamic based on which table/row I select.

Any idea?

```auto
coalesce({../Table.props.selection.data[0].CmdNum}, "None...")

```

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

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 27, 2022, 12:25pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/2 "2022-09-27T12:25:36Z")

</div>

It’s not too difficult. Here is a mockup I’ve done in a flex container that illustrates a straight forward approach using the onRowClick event script. You should be able to easily adapt this model to your usage case. Most people probably prefer the onSelectionChange script for this, but since we are working with two tables, and we probably only want one table to have a selection, this will probably be better.

Here are my components:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b467c8f18fe82017b9ff88175bb53a457fbcf325.png)

Here is what they look line in the view:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/8/2887c23a7a9e8d7f1d24e9af00df749cb302f093.png)

Note how only one table has a selection, and that selection is the one that is displayed in the text fields.

The first table’s onRowClick event script simply removes the selection from the other table, and then writes its current selection to the text fields. Here is the code:

```auto
def runAction(self, event):
	self.getSibling("Table_0").props.selection.selectedColumn = None
	self.getSibling("Table_0").props.selection.selectedRow = None
	self.getSibling("TextField").props.text = self.props.selection.data[0].city
	self.getSibling("TextField_0").props.text = self.props.selection.data[0].country
	self.getSibling("TextField_1").props.text = self.props.selection.data[0].population

```

The lower table’s code is identical except for the fact that it deselects the upper table when clicked. Here is that code:

```auto
def runAction(self, event):
	self.getSibling("Table").props.selection.selectedColumn = None
	self.getSibling("Table").props.selection.selectedRow = None
	self.getSibling("TextField").props.text = self.props.selection.data[0].city
	self.getSibling("TextField_0").props.text = self.props.selection.data[0].country
	self.getSibling("TextField_1").props.text = self.props.selection.data[0].population

```

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [September 28, 2022, 3:07pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/3 "2022-09-28T15:07:13Z")

</div>

> [@justinedwards.jle](#):
>
> not too difficult. Here is a mockup I’ve done in a flex container that illustrates a straight forward approach using the onRowClick event script. You should be able to easily adapt this model to your usage case. Most

Justin,

I am getting any error that says:

```
caused by org.python.core.PyException

```

Traceback (most recent call last):  
File "function:runAction", line 4, in runAction  
AttributeError: 'NoneType' object has no attribute 'props'

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

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 28, 2022, 3:15pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/4 "2022-09-28T15:15:57Z")

</div>

One of your paths must be wrong. The best and easiest approach is probably to get all of your properties using the icon in the top right of your designer window:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/4/8458e55990551727b6dcfc18c387fba262566bd9.png)  
It will prevent a lot of typo type mistakes.

Just select the property you want from the tree, and the designer will automatically insert the correct path into your code.

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [September 28, 2022, 3:21pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/5 "2022-09-28T15:21:13Z")

</div>

I hate to say this but I used a capital letter in the script but named it all in lower case on the text label name.

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [September 28, 2022, 4:09pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/6 "2022-09-28T16:09:53Z")

</div>

One more question if you have time.

In my query that I am pulling to fill the data it is in a date format.  
In the data display of the of the table it is also in a date format.

My issue is when it is displayed in the text field it is a number.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/3/5390b3d15b08f7a1eb35bf5bb21f2a573c9a7ce5.png)

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

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

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 28, 2022, 4:25pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/7 "2022-09-28T16:25:23Z")

</div>

In my testing, I didn’t get that result. Do you have the renderer set to date for your column?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2cda953b518fe28a213be05505282a36c7d6c1b1.png)

Here is the result I am getting:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9704cbf39e5357c0ff01f6e84ce276526011f15.png)

Here us what it looks like in the dictionary:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/81103e0943ae176a4073fac63af79997743acde9.png)

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [September 28, 2022, 5:06pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/8 "2022-09-28T17:06:03Z")

</div>

> [@justinedwards.jle](#):
>
> didn’t get that result. Do you have the renderer set to date for your column?

I changed it to render date and still no date.

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

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [September 28, 2022, 7:58pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/9 "2022-09-28T19:58:12Z")

</div>

you need to add a mapping to those three text fields to map their values to a datetime

Here i added a custom property called `valueIn` (that’s where you’d be writing your value to instead of the `text` property)

Then add a binding on `text` to `this.custom.valueIn` and finally a `Format Transform` setup with whichever datetime format you want to display

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c0db48f4a6ee0c1d770fd367bcb7082b1e412d1f.png)

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [October 6, 2022, 1:56pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/10 "2022-10-06T13:56:28Z")

</div>

Awesome, thank you so much. I have been through all my training and have been doing this for a year but these simple things that are not easy to find always stump me.

---

<div class="post-metadata">

**Author:** ![Matthew.gaitan](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@Matthew.gaitan](https://forum.inductiveautomation.com/u/Matthew.gaitan)\
**Post date:** [October 6, 2022, 2:08pm UTC](https://forum.inductiveautomation.com/t/two-tables-question-using-text-fields/64485/11 "2022-10-06T14:08:17Z")

</div>

One thing to pay attention to that helps is how the data is actually displayed in the property editor.

In the case of the table the timestamp data will be displayed as a long number, while the items in the `columns` config tell the table how to display that data, not necessarily the output format of the data.

Glad you got it working 🙂
