Power Table: problems with formatting the border / intercell spacing

Hello everyone,

I run into problems with displaying a nice looking table in Vision. Using the standard vertical / horizontal grid always generates lines which overlap with the boarder. Those double lines look weird. Trying to find a workaround I tested all possible combinations of grid lines enabled / disabled, custom headers, custom borders (set via scripting), but there is always either a double line or a missing line in some places.
image

Then I moved on to Powertables to completely customize the table grid (which I find a very annoying that this is necessary only to receive a good looking table grid). There I used custom borders on each individual cell.
image
This approach would theoretically work to achieve the desired results, but only with intercell spacing set to 0. Otherwise there is always a space between the lines.
The problem here is that I can not set the intercell spacing to 0. Everytime I do this in the Designer it is set back to 1. I can not modify this value at all, it is always reset to the default value after a few seconds.
So I tried to script it, passing a Dimension object to this property. But everytime the viewDataset changes this property is reset to the default value. And annoyingly every change of the intercell spacing seems to trigger a viewDataset property change event (At least it appears to be so when I trace the property events. Maybe it is something else in the background reseting it to the default value). So reacting to this property change results in an endless loop. Most of the time when the window opens the table loads with intercell spacing - sometimes with a little luck it is displayed with intercell spacing set to 0.

I really do not understand this behavior - is it a bug?
Is there any other way in Vision to get a nice looking, customized table grid?

Yes, the intercell spacing behavior is a bug, but should be fixed in 8.1.6+; what exact version are you using?

We are currently using 8.1.7.

I just noticed that my solution is working when I only have one Powertable in a Window. When I place a second Powertable inside a window this strange behaviour starts.

Ahh, that’s an interesting complication and would definitely suggest a bug. I’ll file an internal ticket to investigate.

Hmm, I’m not able to replicate easily even with multiple power tables.
Also, is there a reason you can’t use the grid built in to the power table instead of overriding inter cell spacing?
With the following I get a table pretty close to what you want, I think:
image
image

For the headers, a configureHeaderStyle implementation like this is pretty good:

	from javax.swing import BorderFactory
	return {
		"background": system.gui.color(128, 128, 128),
		"border": BorderFactory.createMatteBorder(0, 1, 1, 1, system.gui.color(0, 0, 0))
	}

image
Still an incorrectly doubled line; you may be able to solve that by wrapping in compound or empty borders from BorderFactory: BorderFactory (Java SE 11 & JDK 11 )

Thank you for your answer.
The reason I want to use a custom grid is that I want to hide certain elements of the grid. The standard grid can not be controlled. In some cases I just want to hide some of the horizontal bars, but not all. Even if I want to hide all the horizontal bars, there is the problem that when I ‘close’ the table with a lower border line this does not correctly align with the vertical bars. No matter which combinations I try, there is always either an overlap or a double line.

You are right, in your example the table already looks quite good and I would not bother about double lines (which are hard to see beside the scrollbar). However I want to show small, fixed size tables without a scrollbar as shown in my example pictures. In those small tables even a 1-pixel overlap or a double border line looks like ‘unfinished work’.

Those are the two reasons I want to build a custom grid by individually setting the border of each cell.
The weird thing is that the intercell spacing does not always work. I have done some further testing. When I set it to 0 in the designer it gets set back to 1 when loading or scaling the powertable. When I only use one table I can reset it to 0 with scripting. When I have more than one table this workaround no longer works. (When I open the popup window in which the table is located, sometimes it is displaying correctly, sometimes it is not. It is also flickering as if the intercell spacing gets constantly reset to the default value).

Consider trying to use your own cell renderers everywhere, with the tables own grid turned off. Control the borders of the cell renderers yourself.

If i understand it correctly using a custom cell renderer will achieve the same results as using the configureCell()-function of the power table?

With specifying my own grid in the configureCell()-function I can achieve exactly the results I want. Unfortunately this does not work properly because of the weird intercell spacing behaviour mentioned above.

A custom renderer is an alternate return from configureCell(). You supply a JComponent that has the display behavior you desire.

If you can replicate the inter cell spacing problem, can you send a project export in to support?

I was not able to replicate the problem. On the gateway where this project is running we have Ignition 8.1.7 installed. I can not get the intercell spacing to work properly there. However when I was trying to replicate it I copied the project to my local gateway which has Ignition 8.1.10 installed. There I could modify the intercell spacing as expected. I was able to change it in the designer and also in the initialize-function of the powertable and it was not reset to the default value.

So at some point it might be worth upgrading our project gateway to the newest version.

I encountered another similar phenomenon I don't understand. When I set the column size via scripting this always gets reset. Any setColumnWidth()-calls in the initialize function - where I would expect that it should be - or in other places do not have any effect. This also happens in 8.1.10.
I figured out that everytime the viewDataset changes the column size gets reset (not what I would expect - format and data should be different concerns). So the only solution I could come up with is to reset the column size every time the viewDataset changes.
image

Why does the powertable resize everytime the viewDataset changes? And is there any better solution to set a fixed size to columns?

What’s the Auto-Resize Mode set to for your table?
image

Resizing the columns when the data changes is default JTable behavior unless you explicitly set it to ‘Off’.

The Auto-Resize-Mode is set to Off, but still I need to resize the table everytime the viewDataset changes.

Hi,
In designer I have powertable, not showing scroll bar,
but when I launch the designer table showing scroll bar. how to remove scroll bar.


below is launching window, showing scroll bar.
image

please Help

If you never want a scroll bar to appear, add the following script to your power table's initialize extension function:

#def initialize(self):
	from javax.swing import JScrollPane 
	self.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER)
2 Likes

Wow! Thank you, Its working perfect

1 Like

Hi,

can you please guide how to do the same in Perspective table.

Intuitively, I would have assumed that either the overflow or overflowY CSS properties would have overridden this scrollbar, but my initial tests have had no effect on it, so I'm not sure. Perhaps somebody else has some experience with this?

I would create a new topic that asks this specific question and be sure to tag it as Perspective. I imagine that it would draw more attention from the people who already know how to do this sort of thing.

Going off Kavya's questions, is it possible to add a Horizontal scroll bar?

When you say this, I'm imagining that the data in your table is getting squished due to your autoresize mode:

To fix this, simply change the 'Auto-Resize Mode' parameter of your Power Table to Off.
image

Then, your columns will be able to overflow, and you will get your scrollbar automatically:

2 Likes