Added column shows in Designer but not in client

I need some help. In Designer, I used a power table to pull in my data. Then I added a column, so my user could add notes. It all works correctly in the designer. However, when I was testing in the Client Application, the column did not show. I reinstalled the client, and for a split second, it did show up, then it disappeared. When I right-click on the header of the power table to modify the column settings, it is not listed.
Is there a step I am missing or setting?

Sounds like you are both binding to supply data to your table, and scripting changes to that same data property. The binding will keep overwriting what your script generates.

Instead, add a custom dataset property to your table, and move the original binding to that new property. Then your script will read from the new property, and write to data.

Thank you for your help. Yes, you are correct I was binding to the data rather than the dataset view. So, my new column is now appearing, but the string data is not staying as it was in designer for my added column. I am using the function onCellEdited: = system.dataset.setValue(, rowIndex, colIndex, newValue)

I must be missing an update command?

Please show the entire script. (Use the </> button to format it as code after you paste in the forum.)

Well, that is my entire code. :smile: = system.dataset.setValue(, rowIndex, colIndex, newValue)

I read about updating the database; however, I am pulling from a read-only database table. Plus, I added a column, so I guess I need to know how to update my data view. Can you point me to the documentation that I need?
Thank you.

It sounds like you will need another property to hold the values for your new column.

Your onCellEdited script would write the changes to the new property. Then you can configure a valueChange event on the new property to combine the data from the table with the now edited values of the added column and write the combined dataset to data.

You will probably need a way to make the user changes to your added coulmn persistent though, so you might want to look into making the database table read/write and adding the column there. This then becomes much simpler.

Another possible solution if the dataset is not expected to be large, would be to use a memory tag to hold the added column data, which would also make the data persistent across sessions.

Another consideration is if the data needs to be updated across clients/sessions. With your current design it would not, it would only be local to that one client, again the most likely candidates to take care of that are the database or a tag.

Where is that code? On a propertyChange? Should be something like this, after you move the binding:

if event.propertyName=='myCustomProp': = system.dataset.addColumn(event.source.myCustomProp, colIndex, [newValue], 'newColName', 'newColType')

Look at the docs for addColumn

My code is under the extension function onCellEdited. I have tried a few more things trying to work this out. I created a tag “OrderLineNote” as a string array. So my code is:

def onCellEdited(self, rowIndex, colIndex, colName, oldValue, newValue): = system.dataset.setValue(, rowIndex, colIndex, newValue)
system.tag.writeBlocking(['[default]OrderLineNote(rowIndex)'], [newValue])

I only have read access to the database, so I do not have the option of updating the database. As lrose pointed out, the problem becomes the data disappears when closing and reopening the client.

You could start with adding a custom dataset property to the power table. Call it originalData. Then bind that property to the SQL query to get the noteless data from the database. The query will have to include a primary key

Then, you could create a dataset memory tag with two columns: “name of Primary Key” and “Notes”

Afterwards, you would be able to create a custom method called “refreshTable”

The code for the custom method would look like this:

	dataSetOriginal = self.originalData
	dataSetNotes ='[default]yourTagPath/DatasetTag').value
	notesColumnHeader = "Notes"
	notesColumnData = []
	for row in range(dataSetOriginal.getRowCount()):
		notesForPrimaryKeyExists = "false"
		for noteSearch in range(dataSetNotes.getRowCount()):
			if dataSetOriginal.getValueAt(row, "Primary Key") == dataSetNotes.getValueAt(noteSearch, "Primary Key"):
				notesColumnData.append(dataSetNotes.getValueAt(noteSearch, "Notes"))
				notesForPrimaryKeyExists = "true"
		if 	notesForPrimaryKeyExists == "false":
			notesColumnData.append(" ") = system.dataset.addColumn(dataSetOriginal,notesColumnData,notesColumnHeader, str)

This will tie your notes to your database information based on the primary key.

With this approach, the refreshTable method will need to be called from the initialize extention function

Finally, the dataset tag will need to be updated during edits using the onCellEdited extension function. That code will look like this: = system.dataset.setValue(, rowIndex, colIndex, newValue)
	editedDataHeaders = ["Primary Key", "Notes"]
	editedData = []
	for row in range(
		editedData.append([, "Primary Key"), str(, "Notes"))])	
	system.tag.write('[default]yourTagPath/DatasetTag', system.dataset.toDataSet(editedDataHeaders, editedData))

Thank you, this helped me a lot, and I appreciate the time you gave me. The only thing I had trouble with, and was stuck on for a long while, was that the initialize extension function was not executing. I had to finally give up on it and put the refreshTable into a button, and it worked just fine.

Has anybody else had that issue where the code doesn’t execute during initializing? Is there a trick to make it work?

Thank you to everyone else as well!

The initialize extension function fires when the component is first loaded, so it never fires in the designer. However, once the updated script is compiled, the initialize extension function should fire when the window that the power table lives on is first opened.

Also, extension functions are not good for throwing exceptions, so if an extension function bombs out for some reason during execution it can seem like it didn’t fire. It helps to launch the diagnostics console from the help menu to monitor the script. Any errors that occur during extension function execution will be reported there.