[Wiki] system.dataset.toDataSet destroys table customizer fix

I’m using a table to modify one column of various sections of a CSV recipe file. This requires me to erase the table data every time a different recipe or section is selected. This in turn was deleting the customizer and the “editable” property of the column in question.

The workaround is to save the table’s columnAttributesData before the erasure and restore it afterwards.

window = system.gui.getWindow("Main Windows/ParameterEdit")	# Used to reference items on the ParameterEdit window.
# A new recipe or stations selection has been made. Clear the table.
tbl = window.rootContainer.getComponent('tblParams')
customizer = tbl.columnAttributesData						# Save the customizers before we destroy them ...
header = ['Line', 'Description', 'Setpoint', 'Min', 'Max']	# Header rows for the table.
row = []													# Empty.
tbl.data = system.dataset.toDataSet(header,row)				# Create the table dataset.
# The line above destroys the tblParams customizers which includes the "editable" property of the Setpoint column.
tbl.columnAttributesData = customizer						# This line restores the customizer. 

I hope that this is useful.

1 Like

That’s strange. What version is this? Historically, the only thing that would write to a table’s c-a-d dataset was the customizer. Nothing at runtime, unless you did it yourself. For tables that are intended to show multiple different datasets at different times, it has always been possible to grab all of the necessary c-a-d datasets, merge them in a text editor, and paste back into the property. As long as you didn’t use the customizer after that. (You could also paste into a custom dataset property and bind the c-a-d to that property to ensure it always started up correctly.)

Hi, Paul. Version 8.0.15.

As explained, the system.dataset.toDataSet(header, row) seems to change the customizer. I got the impression from some other posts that others had the same problem.

I can try to create a very simple version of the problem tomorrow.