# \[8.0 Vision Client\] Power Table - saving column order/sizing

**URL:** <https://forum.inductiveautomation.com/t/8-0-vision-client-power-table-saving-column-order-sizing/31793>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 30, 2020, 7:54pm UTC](https://forum.inductiveautomation.com/t/8-0-vision-client-power-table-saving-column-order-sizing/31793 "2020-01-30T19:54:27Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 8, 2023, 11:37pm UTC](https://forum.inductiveautomation.com/t/8-0-vision-client-power-table-saving-column-order-sizing/31793/5 "2023-05-08T23:37:34Z")

</div>

> [@Bastian\_Ignacio](#):
>
> Save:  
> id\_user, big string with everything you need

I suppose the easiest route to achieve this would be to use something like the parent window's internalFrameClosed event handler. Then, just simply throw all of the column information into a dictionary that you save to the database.

**Example:**

```auto
userName = system.security.getUsername()
powerTable = system.gui.getParentWindow(event).getComponentForPath('Root Container.Power Table')
table = powerTable.table
columnModel = table.columnModel
columnProperties = {str(column.identifier): {'location': columnModel.getColumnIndex(column.identifier), 'width': column.width} 
	for column in columnModel.columns}

#INSERT or UPDATE the following information:
print userName
print columnProperties

```

Then, when the user first opens the table use a script similar to this to change the table:

```auto
columnProperties = system.util.jsonDecode(yourStoredDatabaseString)
powerTable = event.source.parent.getComponent('Power Table') 
columnModel = powerTable.table.columnModel
def restoreSavedColumnSettings():
	columnsChanging = False
	for column in columnModel.columns:
		column.preferredWidth = columnProperties[column.identifier]['width']
		preferredLocation = columnProperties[column.identifier]['location']
		actualLocation = columnModel.getColumnIndex(column.identifier)
		if preferredLocation != actualLocation:
			columnModel.moveColumn(actualLocation, preferredLocation)
			columnsChanging = True
	return columnsChanging
restorationAttempts = 0
while restoreSavedColumnSettings() and restorationAttempts <= 5:
	restorationAttempts += 1

```

**Edit:** I set up a test window with a power table to test the above scripts, and I discovered that with multiple column moves, more than one iteration is sometimes required to restore the table using the original script. I modified the original script to automatically reattempt [up to 5 times], if the initial column changes do not result in the preferred configuration.

In case it's helpful, here is the test window:  
[testWindow.zip](https://forum.inductiveautomation.com/uploads/short-url/gm847kUZXbHmlqDIc4WALt5y9eu.zip) (44.6 KB)  
The save button saves the column information as a string on a custom property, and the restore button restores the column settings using the custom string property.

---

_[View the full topic](https://forum.inductiveautomation.com/t/8-0-vision-client-power-table-saving-column-order-sizing/31793)._
