Power Table connection to a component

The red one is a power table and the green one is a container I made with component for the power table. I need to connect my components in my container to my power table settings.

I believe this sort of thing with the Power Table's property change event handler. The script will look something like this:

if event.propertyName == 'selectedRow' and event.newValue != -1:
	name = event.source.data.getValueAt(event.newValue, 0)
	label = event.source.data.getValueAt(event.newValue, 1) 
	position = event.source.data.getValueAt(event.newValue, 2)
	nameComponent = event.source.parent. #yourPathtonameComponent
	labelComponent = event.source.parent. #yourPathtolabelComponent
	positionComponent = event.source.parent. #yourPathtoposition Component
	nameComponent.text = str(name)
	labelComponent.text = str(label)
	positionComponent.selectedIndex = int(position)

it works but can i ask if the selected row is selected and appeared on the component can I edit it through the component? example: If i click the name column 1st row then the name of the row will appear in the text field. Can i edit the name that appeared in the text field?

Of course. Looking at your picture, it appears that you are populating your power table with a dataset from your chart, so you would need to write directly to the chart's dataset to have an effect.

More than likely, in all cases, the script will run from the propertyChange event handler of the specific component. For example, if it is a text field, your script will look like this:

if event.propertyName == 'text':
	row = #this will have to be determined somehow. Perhaps a custom property that that saves the last selected row of the power table? ...or I suppose you could simply grab the selectedRow directly from the power table itself
	columnName = #this will be the specific column that the text field represents
	value = event.source.text
	chart = #path to the chart that is populating your table
	dataSource = chart.dataSource #This probably won't actually be called datasource, but replace the word datasource with the specific dataset name that is populating your table
	updatedDataSource =  system.dataset.setValue(dataSource, row, columnName, value)
	chart.dataSource = updatedDataSource 

For a dropdown, the event.propertyName that you would want to use would probably be selectedValue, but you can always throw print event in the property change event hander of any component, and then, just look in the console and see which events get printed out when you execute the change your looking to trigger a script from. This is often how I determine which route to take, and which values to use in scripting.

EDIT: Made the example script a little more complete

Also: Here is a link to the documentation on editing datasets in the way I describe above

1 Like