Two Tables Question Using Text Fields

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?

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

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

Here is what they look line in the view:

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:

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:

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

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’

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
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.

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.

1 Like

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

image

In my testing, I didn’t get that result. Do you have the renderer set to date for your column?
image

Here is the result I am getting:
image

Here us what it looks like in the dictionary:
image

I changed it to render date and still no date.

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

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.

1 Like

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 :slight_smile: