Clearing Data table

I have a page in one of my projects that is basically a 1 column table. That info gets inserted into a SQL database. My problem is that upon return to that page later, there is still latent data there… How can I make sure the table is “empty” when the page is loaded?

Put this in the visionWindowOpened event script on your window:

table = system.gui.getParentWindow(event).getComponentForPath('Root Container.Table').data = system.dataset.toDataSet(["ColumnName"],[])

Maybe it would be better to clear your table after the data is inserted into the database. That would be a matter of adding = system.dataset.toDataSet([“ColumnName”],[]) to the script that inserts the data.

That totally blanked out the column. There were NO CELLS after running this… For the time being after I submit the info to the DB, I shutdown and restart the project. It’s a kludge, but will work until we get the SPC fully implemented.

You need to put the correct names of the columns in the system.dataset.toDataSet function call. My code was only an example because I don’t know what your column names are.

The first argument to system.dataset.toDataSet is a Python list of the column names of the table.

I think I understand the problem. You have a table with a single column of blank data that you want the user to fill in, and you want the user to see the data as blank ROWS every time they open (or activate) the window.

The second line of code that nmudge presented is what is “blanking” out the table completely (NO ROWS). You’ll need to append the empty rows to the dataset. Here is the code I think you want:

COLUMN_NAME = "ColumnName"
TABLE_NAME = "Table"

table = system.gui.getParentWindow(event).getComponentForPath("Root Container." + TABLE_NAME)
dsEmptyData = []
for i in range(NUM_OF_ROWS):
	dsEmptyData.append([None]) = system.dataset.toDataSet([COLUMN_NAME],dsEmptyData)