# Powertable Column Width

**URL:** <https://forum.inductiveautomation.com/t/powertable-column-width/20001>\
**Category:** Ignition\
**Created:** [October 5, 2018, 5:53pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001 "2018-10-05T17:53:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.panici](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/christopher.panici/32/5814_2.png) [@christopher.panici](https://forum.inductiveautomation.com/u/christopher.panici)\
**Post date:** [October 5, 2018, 5:53pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/1 "2018-10-05T17:53:55Z")

</div>

Is there an easy way to set the column widths and have the widths save? I am not opposed to doing it in a script. For example, giving the template an array of numbers as a custom property then setting the column widths on the Initialize method?

Thanks in advanced,  
christopher

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [October 5, 2018, 6:05pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/2 "2018-10-05T18:05:30Z")

</div>

What’s up Neech? ESE Alumni here…

I usually create a custom method on the power table, something like this:

```auto
# Set the column width for the table
self.setColumnWidth(0,60)
self.setColumnWidth(1,400)
self.setColumnWidth(2,60)

```

---

<div class="post-metadata">

**Author:** ![christopher.panici](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/christopher.panici/32/5814_2.png) [@christopher.panici](https://forum.inductiveautomation.com/u/christopher.panici)\
**Post date:** [October 5, 2018, 6:06pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/3 "2018-10-05T18:06:49Z")

</div>

Hey dude! Thanks for the response! I will try that.

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [February 27, 2019, 9:19pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/4 "2019-02-27T21:19:04Z")

</div>

Paullys50, Would you please show us exactly how this Custom Method is configured.  
Thanks

 ![Custom%20Method%20Column%20Width](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/0ce888a0330a6dd929fa34ae89326c1449a421cc.png)

---

<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:** [March 14, 2019, 12:41pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/5 "2019-03-14T12:41:16Z")

</div>

once you create the custom method you have to call it for it to run. I’ve used this by calling the custom method from another component, but you can call it from the same component it’s in.  
in the ColumnWidth function put something like

```auto
self.setColumnWidth(0,200)
self.setColumnWidth(1,100)
self.setColumnWidth(2,300)

```

to run it from another component just put in this script

```auto
event.source.parent.getComponent('Power Table').ColumnWidth()

```

calling the method from the same component use

```auto
event.source.ColumnWidth()

```

[custom method link](http://10.10.0.115:8088/main/system/help/Component_Custom_Methods.html)

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [March 14, 2019, 6:40pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/6 "2019-03-14T18:40:50Z")

</div>

Thank you for your response.  
I’m still having some trouble, will you take a look at what I have and see if anything stands out to you. What about the “Parameters” box?

 ![powerTableCustomMethodforColWidth](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f7b94244cfb7fa4025b6e61419fd8fbb62fd3c1b.png)

---

<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:** [March 14, 2019, 7:05pm UTC](https://forum.inductiveautomation.com/t/powertable-column-width/20001/7 "2019-03-14T19:05:26Z")

</div>

I don’t see any issue here. The parameters box is if you want to pass a variable into the function. This function does not need a parameter passed into it to accomplish the set column width.

So if you wanted to make sure the column width is always correct you could apply this script to the propertyChange event.

```auto
if event.propertyName == 'data':
     event.source.ColumnWidth()

```

Lets say you use a custom method later on that you want to pass a value of a calculation into the custom method to do an error check or something you would do this from where ever you are performing the calculation

```auto
event.source.customMethod(calculation result)

```

This call passes the calculation result as a parameter into the custom method for validation. A custom method without a parameter is called with the parenthesis empty.

EDIT: Also set the table’s resize mode to off!
