Hello.
Is there a way to vertically center text in a power table, while still letting it wrap?
It doesn't seem like this thread was able to find a solution Power Table Wrap Text - #5 by bvaldovinos
(as the other user said, using configureCell's
if colName == 'spec_description' : return {'verticalAlignment' : 2}
does not override the alignment)
Interestingly, simply returning the 'text'
property with html doesn't work; it just displayed the string with the html tags in the front. However, changing the text property of the renderer directly does produce the desired result.
Example:
#def configureCell(self, [...], colView):
# Wrap and center string text
if self.table.getColumnClass(colView).__name__ == 'String':
# Could be less genarically written as if colName == 'String Column': # or whatever the actual name ends up being
# Set the alignment properties and inject HTML into the text
renderer = self.table.defaultCellRenderer
renderer.setHorizontalAlignment(renderer.CENTER)
renderer.setVerticalAlignment(renderer.TOP)
renderer.text = '<html><center>' + textValue
# Return the modified renderer
return {'renderer' : renderer}
Result:
2 Likes
As a note for anyone reading this,renderer.setHorizontalAlignment(renderer.CENTER)
seems to affect cells with only one line, whereas renderer.text = '<html><center>' + textValue
affects only cells with multiple lines.
So to left justify the text, I changed both from center to left.