# Table Column Attributes Data Binding to another table

**URL:** <https://forum.inductiveautomation.com/t/table-column-attributes-data-binding-to-another-table/85037>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [January 31, 2024, 6:53pm UTC](https://forum.inductiveautomation.com/t/table-column-attributes-data-binding-to-another-table/85037 "2024-01-31T18:53:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [January 31, 2024, 6:53pm UTC](https://forum.inductiveautomation.com/t/table-column-attributes-data-binding-to-another-table/85037/1 "2024-01-31T18:53:28Z")

</div>

I have a 4 Tables with the same Columns Qty and Names. i would like to see if it is possible to bind the "Column Attributes Data" of a table to another table "Column Attributes Data" , so that they are Bind and the same , TABLE 1 to TABLE 2, TABLE 3 AND TABLE 4. meaning that if i adjust the width of a column on TABLE 1 . the other TABLES adjust the same .

so that the operator and designer does not need to adjust Table columns to make them match .  
here is a screenshot of how I display the tables in window. any ideas?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2d542d5b43bdb31d173ab6d8f28e74309df0400.png)

---

<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:** [February 1, 2024, 1:59pm UTC](https://forum.inductiveautomation.com/t/table-column-attributes-data-binding-to-another-table/85037/2 "2024-02-01T13:59:54Z")

</div>

Are these Table components or Power Table components?

---

<div class="post-metadata">

**Author:** ![juang](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@juang](https://forum.inductiveautomation.com/u/juang)\
**Post date:** [February 1, 2024, 3:26pm UTC](https://forum.inductiveautomation.com/t/table-column-attributes-data-binding-to-another-table/85037/3 "2024-02-01T15:26:05Z")

</div>

Table components.

---

<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:** [February 1, 2024, 4:03pm UTC](https://forum.inductiveautomation.com/t/table-column-attributes-data-binding-to-another-table/85037/4 "2024-02-01T16:03:33Z")

</div>

I'm not sure how you could bind it because the attributes data property is not a bindable property on the table. Also, the attributes data propertyChange event won't occur outside of the designer. You could play around with developing a column model listener to synchronize the columns. Here's a quick example to get you started:

```auto
# Written for the table's propertyChange event handler
# Runs only once at initialization when the window is first opened
# Won't run in designer unless preview mode is on prior to the window being opened
if event.propertyName == 'componentRunning':

	# Implement a custom table model listener class
	from javax.swing.event import TableColumnModelListener
	class ColumnModelListener(TableColumnModelListener):
		def __init__ (self):
			pass
		def columnSelectionChanged(self, event):
			pass
		
		# If adding, removing, and moving columns is allowed,
		# ...develop the next three methods to synchronize that
		def columnMoved(self, event):
			pass
		def columnAdded(self, event):
			pass
		def columnRemoved(self, event):
			pass
			
		# Synchronize the column widths here:
		def columnMarginChanged(self, event):
			# Get the current widths of the top table
			widths = [column.width for column in event.source.columns]
			
			# I had to add this to ensure the columns in my tables had an equal range of motion
			# column.minWidth = 0
							
			#Iterate through the other tables and syncronize the widths
			for table in [tableTwo, tableThree, tableFour]:
				self.setColumnWidths(table, widths)

		# Create a custom method within the class for setting the widths of each table
		# ...so there are not four copies of the same code for each table
		def setColumnWidths(self, table, widths):
			for index, column in enumerate(table.columnModel.columns):
				column.minWidth = 0
				column.preferredWidth = widths[index]
	
	# Assign the table components to unambiguous variables for use by the listener
	tableOne = event.source.parent.getComponent('Table 1').table
	tableTwo = event.source.parent.getComponent('Table 2').table
	tableThree = event.source.parent.getComponent('Table 3').table
	tableFour = event.source.parent.getComponent('Table 4').table
	
	# Create an instance of the listener and assign it to the table
	listener = ColumnModelListener()
	tableOne.columnModel.addColumnModelListener(listener)

```

**Result:**  
 ![Screen Recording 2024-02-01 at 9.48.13 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/8/9812890167d167f8d0e50ab4aeca20ce4515af43.gif)

**Edit:** Removed improperly placed `column.minWidth`
