You also can click on the table, then in the properties pane, click on the icon that looks like a little table beside the data property. From there you can create a dataset without scripting it, however you still have to type the data.
If I put this in the “Client Project Script” so that it executes when client project starts will this not create a “DATASET” tiltled DP?? I want this dataset to be available for the project.
I’m not sure if this is a function of how the code got from Ignition to forum post or an issue in your code, but the code as posted is using curly quotation marks that will throw an error. Put triple back ticks (```) on a line above and below your code in forum posts to make it format well like below. Here’s your code with curly quotation marks replaced. I used single quotation marks, but plain/straight double quotation marks would work as well. The code below will create a dataset like you’re looking for:
The other issue is where to put this code. The client startup script event’s parent will not be the container holding the table. You would need to make sure the window is open, get a handle to the window, and then drill down to the table component. Instead, you could:
Assign the value to a memory tag and bind DPTable.data to the memory tag.
system.tag.write('dpData', DP)
Or put the script in the table’s event script like this:
You placed the script in the propertyChange event handler for the table, but then you are looking for the event.propertyName to be equal to ‘Container 1’. Unless I’m missing my guess this is never the case and so your script is not executing. Notice how @witman script is looking for event.propertyName to be equal to compoenentRunning.
Since you are generating this data set in a script you don’t need to bind the data property. Bindings are used to map external sources to properties, you’re script is an internal source.
If I add a (Table Object) to my window and I name it (DPTable) how do I get it to show the data from this (DataSet) see picture (Note this scripts gives me an error.)
You have asked that question and it has been answered. There are differences between your script and the script that was given. I am sure that is where the issue lies.
When you define data you are using parenthesis where you should be using square brackets.
Also, you have parenthesis around the string comparison, which shouldn’t be hurting anything but is really not needed.
Both @witman and @dkhayes117 have provided scripts to do the task you’re wanting done.
If the script is giving an error, tell us what the error is and we will help you correct the issue.
You have a capital ‘D’ on data on the last line of your script. Fix that. In the future, show your errors in full. (Use triple-’ formatting on those, too, just like code samples.)
Not just you... much easier to troubleshoot code I can copy and paste into the script console than from a screenshot (says the guy who just posted code in a screenshot). Showing full error is very helpful too.
@dcamp1 you've probably figured this out from feedback above, but if you paste the code below into the property change event of the table you want the data displayed in, it should work:
New Error.
‘’'Traceback (most recent call last):
File “event:propertyChange”, line 13, in
IndexError: Row 0 doesn’t have the same number of columns as header list.
at org.python.core.Py.IndexError(Py.java:250)
at com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities.toDataSet(DatasetUtilities.java:489)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:404)
at org.python.core.PyObject.__call__(PyObject.java:408)
at org.python.pycode._pyx2.f$0(<event:propertyChange>:14)
at org.python.pycode._pyx2.call_function(<event:propertyChange>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:636)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:180)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.access$000(ActionAdapter.java:40)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter$ActionRunner.run(ActionAdapter.java:286)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Not relevant in this case as you’ve resolved it, but the error you posted refers to line 13 of your property change event code, so you’d want to post your code along with the error in the future for troubleshooting help (there aren’t 13 lines in the code we provided and we may be able to see the matrix, but can’t quite see your monitor–yet). Glad you got it figured out!