Auto center in power table

Here is my problem

  • i created a powertable with a few dropdown beside the table , these dropdown are used to select different option that the user can select to show a different query in the powertable.
    to generate the query i use a python script that i inserted on a button that i called “search”.
    so when the user press search depending on the selection he made on the dropdown it will generate a different query in his power table.
    the problem i have is that the column that the query generate are not allway the same .
    col name ex 1: Date , day ,shift , piece per bundle
    col name ex 2: Date , day ,shift , pellets per bag
    So when the 4th column name change , the whole column text auto align to left because it automaticaly fall into “auto align”, i can change them in table customizer but as soon as the name change he forget the previous alignment and swith to auto and the whole column aligne to left .

i wish this is clean enough for you guys im french as main language and i tried to be as clear as possible !
Thx :wink:

You can set the width of the columns in code.
After your code to change the data source, run this for any columns you need to resize

tbl = event.source.parent.getComponent(‘tblSearch’)
tbl.setColumnWidth(0, 15)
tbl.setColumnWidth(1, 25)
tbl.setColumnWidth(2, 55)

Thanks for your fast answer !
I didnt know that but this is not really what i was talking about , its the text in the colomn that i need to be centered.

Ahh ok.
Under Scripting on the Power Table, go to the configureCell extension function.
Then enable it and add something like this for each column you want the text centered.

if colIndex==2:
	return {'horizontalAlignment':0}
1 Like