Scripting & Binding

Hello All,

I have a table (lets call it “table 1”)on a screen displaying OEE and Throughput information. On the same screen i have a pie chart showing my downtime to operating time ratio (Lets call it “Chart 2”)

Question:

Is it possible to set the data binded to “Chart1” to the row selected by the user in “table 1”

Right now I have “Chart 1” binded to a SQL statement

SELECT Operating_Time, Downtime_Total FROM p4oee order by p4oee_ndx desc limit 1

And would like to give the users to view “Chart 1” data based on row selection from “table 1”

“Table 1” SQL Binding:

SELECT
Actual_Footage,
OEE * 100,
Planned_Time / 60,
Operating_Time / 60,
Downtime_Total / 60,
t_stamp
FROM p4oee
ORDER BY t_stamp DESC

Thanks
JP

Answered my own Question

WhereClause =

if({Root Container.Pilger 4.Table 1.selectedRow} = -1,

"n/a", // this is the fail case

{Root Container.Pilger 4.Table 1.data}[{Root Container.Pilger 4.Table 1.selectedRow}, "p4oee_ndx"])

Chart1 SQL Binding =

SELECT Operating_Time, Downtime_Total FROM p4oee Where p4oee_ndx ={Root Container.Pilger 4.WhereClause}

I’ve tried finding the answer, but how do I capture multiple selected values/strings in a table?

The standard expression works great for a single selection, but I wish to return the results from a multiple interval selection into a SQL query.

The expression is:
if({Root Container.tblFeatureID.selectedRow} = -1,
“n/a”, // this is the fail case
{Root Container.tblFeatureID.data}[{Root Container.tblFeatureID.selectedRow}, “FeatureID”])

and the SQL query is:

select Operid, Sampleid, Featureid, Nominal, Actual, Deviation, Lowertol, Uppertol, Pass_Fail, Notes
from tblReporter
where FeatureID = ‘{Root Container.tblFeatureID.SelectedValue}’
order by SampleID

Rather than using an expression, with scripting you could use the getSelectedRows() method on the table to iterate through each row and build a string to use in your SQL query:

for row in event.source.parent.getComponent(‘Table 1’).getSelectedRows():
#use event.source.parent.getComponent(‘Table 1’).data.getValueAt(row,“yourColumn”)

You could put a dynamic string property on the table and when the selected row(s) change, fire off a script to rebuild the string, and use that string in your SQL query.

Dan