Power Table - Save Configuration in Client

Is there a property which stores the configuration (which columns are selected, their order and their widths) as the user modifies the power table in the client run time?

In the designer, when previewing the table. I can see that the property “Column Sizing” is a string which updates for each change, such as adding or swapping columns. This allows me to set a default configuration for the Power Table. However when the project is launched this property no longer updates.

I would like to be able to allow users to modify the table the way they want it and then save that configuration so it can be recalled at any time. This way different users could customize the view of the table the way they prefer.

I was able to get this functionality working. You are able with a script to read all attributes of the table in the client run time: (the names of the currently visible columns and their widths). With that data you can build your own the “Column Sizing” string in the same format as the one created in the preview mode of the designer. Then if you bind your created string to the table’s “Column Sizing” property, the table will snap back into the state it was when you created the string.

Hi I’m struggling with this as well. Would you be willing to post an example?

Thanks!

Can you post an example?

I’m not sure why you’re not getting any replies to this, but I am doing this successfully in Ignition 7.9.9.

I have a table whose columns are very numerous and change dynamically based on the division of the company whose data you are viewing. I created a button so that each user can save their column order and widths for each location in a database. Here is the actionPerformed script for the button.

import sys
#Retrive user id from username
un = system.tag.read("[System]Client/User/Username")
uname = un.value
vallst = [uname]
qry = "SELECT ID from [dbo].[tblPeoplelist] WHERE ADUsername = ?"
rtn = system.db.runScalarPrepQuery(qry,vallst)
#print("Username was: %s    ID was %s  and check for INT is:%s" % (vallst[0],rtn,isinstance(rtn, (int, long))))
#sys.exit()
if not isinstance(rtn, (int, long)):
# Couldn't find a used id from the username
	system.gui.messageBox("Sorry, I don't know who you are.\n\nYou must be logged in with your Interfor username and\n" \ 
							"that user name must be entered into the Interfor personnel list\nwith the Personnel Manager\n\n" \ 
							"I see your username as: \n\n%s" % (uname))
	sys.exit()
empid = rtn
loc = event.source.parent.getComponent('ddLocation').selectedValue

if loc < 1:
#	Don't have a location selected in the drop dowm
	system.gui.messageBox("You need to pick a location in the Location drop down box")
	sys.exit()
#	Check to see if we need to update an existing saved layout or create a new one
qry = "SELECT COUNT(ID) from [dbo].[sftyTrnLayouts] WHERE Emp = ? AND Location =?"
vallst = [empid,loc]
rtn = system.db.runScalarPrepQuery(qry,vallst)
tbl = event.source.parent.getComponent('ptTrainingTable')
layout = tbl.defaultColumnView
vallst = [layout,empid,loc]
if rtn:
#	There was already a layout saved for this user and this location, so just update it
	qry = "UPDATE [dbo].[sftyTrnLayouts] SET Layout = ? WHERE Emp = ? AND Location =?"
	value = system.db.runPrepUpdate(qry, vallst, "MillDB")
else:
#	There wasn't already a layout saved for this user and this location, so we need to insert a new record
	qry = "INSERT INTO [dbo].[sftyTrnLayouts]([Layout],[Emp],[Location]) VALUES (?,?,?)"
	value = system.db.runPrepUpdate(qry, vallst, "MillDB")

And then I have a button that (whose script isn’t well documented) that retrieves the saved layout and applies it to the table.

import sys
un = system.tag.read("[System]Client/User/Username")
uname = un.value
vallst = [uname]
qry = "SELECT ID from [dbo].[tblPeoplelist] WHERE ADUsername = ?"
rtn = system.db.runScalarPrepQuery(qry,vallst)
#print("Username was: %s    ID was %s  and check for INT is:%s" % (vallst[0],rtn,isinstance(rtn, (int, long))))
#sys.exit()
if not isinstance(rtn, (int, long)):
	system.gui.messageBox("Sorry, I don't know who you are.\n\nYou must be logged in with your Interfor username and\n" \ 
							"that user name must be entered into the Interfor personnel list\nwith the Personnel Manager\n\n" \ 
							"I see your username as: \n\n%s" % (uname))
	sys.exit()
empid = rtn
loc = event.source.parent.getComponent('ddLocation').selectedValue
if loc < 1:
	system.gui.messageBox("You need to pick a location in the Location drop down box")
	sys.exit()
qry = "SELECT COUNT(ID) from [dbo].[sftyTrnLayouts] WHERE Emp = ? AND Location =?"
vallst = [empid,loc]
#print("Returned value was:%s" % (rtn))
#sys.exit()
if rtn:
	qry = "SELECT [Layout] FROM [Mill].[dbo].[sftyTrnLayouts] Where Emp = ? AND Location = ?"
	layout = system.db.runScalarPrepQuery(qry,vallst)
	tbl = event.source.parent.getComponent('ptTrainingTable')
	tbl.defaultColumnView = layout
else:
	system.gui.messageBox("Sorry, I don't have a layout saved for you for this location")

Note: I have not been able to do anything with the columnAttributesData property. I can change that with a script, but the table will not reflect the properties. So this will only change column order and column width.