How to bind a query in DataHub to a listbox in WebView
This example shows how to use the output of a Query in the DataHub WebView to populate a listbox. This example assumes you are using the DataHub ODBC interface to get the query result. In the result of the query is being written to a "While data set" and you leave the "Use Excel format instead of XML" disabled.
The query I am using is "Select * from DetailMode". The query returns the following results and is written to a DataHub tag called "default:WholePoint".
|
TagName |
TagValue |
TagTimestamp |
TagQuality |
|
Simulation.Functions.Ramp1 |
95 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Ramp2 |
156.5 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Ramp3 |
719 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Ramp4 |
485 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Random1 |
0 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Random2 |
530 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Random3 |
-253 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Random4 |
138 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Sine1 |
-7.40883 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Sine2 |
7.408828 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Sine3 |
14.56126 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.Sine4 |
14.56126 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.User1 |
Hello |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.User2 |
1.25 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.User3 |
1 |
9/7/17 7:27 AM |
192 |
|
Simulation.Functions.User4 |
display |
9/7/17 7:27 AM |
192 |
This will show you how to bind this query result to a listbox control in WebView.
- Open WebView and add a Listbox control to your page.
- Go to the 'Items Source' property of your listbox.
- Set the Binding to Script and use the following: "
GET("default:WholePoint").TableData;" - Click the Apply button and the script will execute.
- Now the 'Display Member Path' and 'Selected Value Path' properties will be populated with the column names from your query.
- For my example I set 'Display Member Path' to TagName and 'Selected Member Path' to TagValue. This will display the TagName in the listbox, but when selected, the TagValue will be the output of the 'Selected Value' property.
- If you want to use this 'Selected Value' in another control, you can do a simple binding to the "ListBox1@SelectedValue" property.