# Power Table limit column size

**URL:** <https://forum.inductiveautomation.com/t/power-table-limit-column-size/38598>\
**Category:** Ignition\
**Tags:** ignition80, vision\
**Created:** [September 11, 2020, 2:16pm UTC](https://forum.inductiveautomation.com/t/power-table-limit-column-size/38598 "2020-09-11T14:16:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 11, 2020, 2:16pm UTC](https://forum.inductiveautomation.com/t/power-table-limit-column-size/38598/1 "2020-09-11T14:16:14Z")

</div>

Vision v8.0.15 - Power Table

I have this code on the Property Change event for the power table:

```auto
from com.jidesoft.grid import TableUtils
from javax.swing import JTable
	
if event.propertyName == "data":
	table = event.source.getTable()
	table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)
	TableUtils.autoResizeAllColumns(table)
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
	TableUtils.autoResizeAllColumns(table)

```

For the most part this does what I need. However, is there a way I can limit a column size? Or better yet, on large columns any way to do word wrap and make that row larger?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 11, 2020, 3:36pm UTC](https://forum.inductiveautomation.com/t/power-table-limit-column-size/38598/2 "2020-09-11T15:36:08Z")

</div>

I looked at [Java’s JTable methods](https://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html) and nothing jumped out at me to accomplish what you are asking with wrapping. For max size you would probably have to loop through all of the columns using `getColumn()` determine if it is over the max width, then alter it if true with `setPreferredWidth()` method.

```auto
colCount = table.getColumnCount()
for i in range(colCount):
    if table.getColumnModel().getColumn(i).getPreferredWidth() > 150:
        table.getColumnModel().getColumn(i).setPreferredWidth(150)

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 11, 2020, 6:20pm UTC](https://forum.inductiveautomation.com/t/power-table-limit-column-size/38598/3 "2020-09-11T18:20:51Z")

</div>

Thanks, all I really needed is set a max, so,

```auto
table.getColumnModel().getColumn(5).setPreferredWidth(550)

```

works just fine for me regardless of what is in the cell.
