Binding Label to Table Data

Good afternoon Team,

I have a table that runs a query to only show errored crane commands. When I get an error it populates into the table.

I have text fields I would like to pull the data from the tables into. One text field per table data point.
I have written the code below that will pull the information but it only pulls when the row in the table is selected. I want the text field to display the information so that I can hide the table.

In addition, I would the Time fields to show nothing until the table is populated. If I coalesce and use " " it shows a date rather than nothing.

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

This feels like entirely the wrong way to approach this.

Why not use embedded views on the table? Or, possibly better, a flex repeater?

I don't really see what having a (hidden?) table is doing for you here besides complicating things. You don't need a table component to get a dataset or array property; any custom property can be made to be an array or object type.

1 Like

It probably is the wrong approach, probably many things I have built are the wrong approach, that is why I come here for guidance.

I am not fortunate enough to have really good training and I am trying to figure it all out myself.

I will look into the flex repeater to see if i can figure it out.

Thanks

Ok, so I have created a Flex Repeater for my table data.

Back to my original problem, unless there is something else.

I would prefer that my date fields to show "None".

I have tried the following and I can get the date to show blank or whatever string I would like.
In doing this I create a 'null' or a 'value' which is then transformed into date.

try(if...
coalesce

Any suggestions?

Thanks

Andrew

I'm not certain I follow what you're trying to do but I'll take a stab at it and hopefully point you in the right direction. I think you're saying you have a 1:1 relationship from textboxes to database fields and those textboxes should either have a date for when the last error occurred or "None" and those are populated from a database query.

Your query returns one row from the database with a value that is either a date or a null and you want the box to say "none" if it's null.

If you're planning to use a template repeater I would use that as the primary UI element. In that scenario you would have a view that contains a label that is populated with whatever value you pass into a parameter. Your template repeater would point to that template and then you can put a binding on the "instances" property that queries your database and populates your template instances based on the results. You want to bind that to whatever event you want to trigger it to update and then put a script transform on it to actually build the json.

Example pseudo code with a parameter called "LabelText"

instances = []
instance = {}
instance['LabelText'] = 'sample text'
instance['instanceStyle'] = {'classes': ''}
instance['instancePosition'] = {}
instances.append(instance)	

return instances

This code shows you how to build the content for the flex repeater. You would change "sample text" to the value from your data. The flex repeater allows you to make it more dynamic. You could just add code to run a named query to pull the data which you iterate and dump into your template repeater with your script transform formatting things for you.

1 Like