# Trouble with adjusting table font size within a template?

**URL:** <https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [August 31, 2023, 1:28pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617 "2023-08-31T13:28:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 31, 2023, 1:28pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/1 "2023-08-31T13:28:42Z")

</div>

Using 7.9.23.

I have an application where I need to show the same table with the same functionality in 3+ different spots so I made a template that is just a power table, and the template parameters are mostly just fed into the Named Query parameters.

I realized though these tables are different sizes in these different areas and I needed the ability to adjust how they look from the parameters too so I added two more parameters `rowHeight` and `fontSize`, the power table rowHeight property bindes right to that, and I handle the font size parameter with a change script on the template like so -

```auto
if event.propertyName == 'fontSize':
	from java.awt import Font 
	table = event.source.getComponent('Power Table')
	table.font = Font('Dialog', 0, event.newValue)

```

But it seems like I don't really have control, the font size reverts. In the following gif I have the fontSize param bound to a numeric text label and you can see what happens, it's most obvious when I try to set it to 18 (think I forgot to hit enter on 14).

![2023-08-31 09-23-16](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/9/a92d41f6e22ef2986699a147f7da9ec2bf3ce363.gif)

I don't know that anything is wrong with my script, my hunch is that the template holder itself is doing some resizing here or something?

There is a `configureCell` script but I don't think it should be interefering its as follows -

```auto
	# This adds row background color based on severity
	data = self.data
	if data.getValueAt(rowIndex, "Hot_Topic") == "New Topic":
		return {'background': 'FFCCCC'}
	elif data.getValueAt(rowIndex, "Hot_Topic") == "Milestone":
		return {'background': 'CCFFCC'}
	elif data.getValueAt(rowIndex, "Hot_Topic") == "Emerging Problem":
		return {'background': 'FFFFCC'}
	else:
		return {'background': 'white'}

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 31, 2023, 2:35pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/2 "2023-08-31T14:35:06Z")

</div>

> [@bkarabinchak.psi](#):
>
> There is a `configureCell` script but I don't think it should be interefering its as follows -

If you disable this script, does the font size change? Alternately, you could try returning `'fontSize': yourCustomProperty` in your configure cell.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 31, 2023, 2:53pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/3 "2023-08-31T14:53:31Z")

</div>

In 7.9 there is no `fontSize` but doing it all inside of configure cell with `font` seems to work as expected

```auto
	from java.awt import Font 
	font = Font('Dialog', 0, self.parent.fontSize)
	data = self.data
	returnDict = {'font':font}
    # other attributes to follow

```

Appreciate the help.

Just disabling the configureCell and trying to do it from the parent template like I was originally doing it was still giving me the flip-flopping behavior for what it's worth. Not that I really care anymore that there is a working method.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 31, 2023, 2:55pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/4 "2023-08-31T14:55:23Z")

</div>

> [@bkarabinchak.psi](#):
>
> but doing it all inside of configure cell

Jeez, dude. Make a constant in a project library script. Or use `.putClientProperty()`. `configureCell` is called a million freaking times as Swing paints components.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 31, 2023, 2:55pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/5 "2023-08-31T14:55:57Z")

</div>

Or a custom property running the `toFont` expression function. But yeah, something better than all those allocations 🙂

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 31, 2023, 3:02pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/6 "2023-08-31T15:02:21Z")

</div>

Trying to get it to work first before making it pretty and put into a library. I don't think it is though further inspection.

@paul-griffith seeing stuff like this now -

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/06d7ee25bf1493d598016a1563008014be3b8043.png)

Seeing some weird behavior where if the Project Status column has a lot of text the whole row is much smaller in two of my template instances (one pictured above) but in my third instance it works fine lol

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

So now I'm kind of at a loss now why it looks so different. Obviously the size is different between these two instances but I don't know why only one is affected with making the font smaller on these particular rows vs the other instance not shrinking the text of the row.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 31, 2023, 3:25pm UTC](https://forum.inductiveautomation.com/t/trouble-with-adjusting-table-font-size-within-a-template/78617/7 "2023-08-31T15:25:09Z")

</div>

Was just a typo. Final script that worked for me -

```auto
from java.awt import Font 
# This adds row background color based on severity (Hot_Topic):
FONTS = {
	'personalized':Font('Dialog', 0, 18),
	'status':Font('Dialog', 0, 16),
	'addRemove':Font('Dialog', 0, 14)
}

COLOR_MAPPINGS = {
	"Hot Topic":"FFCCCC",
	"Milestone":"CCFFCC",
	"Emerging Issue":"FFFFCC"
}

def configureCell(self, rowIndex):
	font = FONTS[self.parent.fontSize]
	data = self.data
	
	returnDict = {'font':font}
	hotTopicValue = data.getValueAt(rowIndex, "Hot_Topic")
	returnDict['background'] = COLOR_MAPPINGS.get(hotTopicValue, 'white')
	return returnDict

```

then I called this in configure cell. Thanks!
