Thanks for your help - I’ve finally worked out what I was doing wrong and have used Nathan’s suggestion to come up with a simpler solution.
To deal with what was going wrong first, I was binding the
SELECT * FROM pens WHERE false
as a SQL query of the Dynamic Property, rather than as an expression (the Dynamic Property is a string). This was then complaining immediately that the query returned no rows.
I was also putting the expression to find the selected value of the list
{Root Container.lstAvailableTrends.data}[{Root Container.lstAvailableTrends.selectedIndex},0]
into an SQL query tied to the chart’s Pens dataset, instead of into an expression. Instead of returning the selected value, it returned a string like
DataSet [3R x 1C][1,0]
which of course totally wrecked the query it was embedded in.
Here’s what I finally have:
- A list tied to the following SQL statement:
SELECT DISTINCT Trend_Name
FROM trend_configuration
ORDER BY Trend_Name
(I have also linked its Selected Index to an expression of -1, so that no value is selected in the list when the window is opened, despite it being cached.)
- A string Dynamic Property of the root container called “TrendQuery”, which has the following expression:
if ({Root Container.lstAvailableTrends.selectedIndex}!=-1,"SELECT Trend_Name as Name, Pen_Name, Col_Name, Table_Name, Axis FROM Trend_Configuration WHERE Trend_Name='" + {Root Container.lstAvailableTrends.data}[{Root Container.lstAvailableTrends.selectedIndex},0] + "' ORDER BY Pen_Number","SELECT * FROM Trend_Configuration WHERE false")
- An Easy Chart with its pen dataset SQL query set to:
{Root Container.TrendQuery}
This all works well, with one reservation: if the user opens the Trending window and selects a configuration, data will be displayed in the graph. If the user then displays some other windows and returns to the Trending window while it is still in the cache, there will be a delay while data for the last graph is fetched and drawn, before the graph is then cleared.
Is there any way of clearing the graph of data on the way out, short of just stopping the window from being cached? I can’t seem to set either the list Selected Index or the Chart Pen dataset from code when exiting.