Is the GridPanel
documentation wrong when it says “Each row has twelve columns” or is the GridPanel
not working as expected?
-
If I put a
GridPanel
inside analert
withlarge=True
, then theGridPanel
has 12 columns.
This works as documented and expected. -
If I add more than 12 items to a row, the items in excess spill into the next row.
This is not documented and unexpected. I would rather have an error than components on the wrong place, but I can live with it. I’m not going to complain when I get into trouble because I’m looking for trouble.
-
If I put a
GridPanel
inside analert
withlarge=False
, then theGridPanel
has 8 columns instead of 12.
This is undocumented, unexpected and I don’t like it.
for n in range(15):
grid_panel.add_component(Label(text=str(n)), row='x', col_xs=n, width_xs=1)
I am working on a custom component that could be used in an alert, and the custom component doesn’t know whether the alert is large or not, or even whether it is inside an alert or not.
I used a GridPanel
assuming that its behavior would be predictable, but apparently I was wrong.
So my question is:
- Can a
GridPanel
know how many columns it has? - If not, is the 8 column behavior described above an error and are there plans to fix it any time soon?
- If not, can I have some directions on how to use a
ColumnPanel
from code?
I understand that working from code with a ColumnPanel
is intentionally undocumented and it’s going to be difficult, but better difficult than wrong.
I tried to reverse engineer the behavior looking at how it is stored in the yaml file, but I failed miserably.
EDIT
Well… may be there aren’t 8 columns after all, it just has as many columns as it likes.
Here is what happens if I add 15 labels on the same row and on 15 different columns: only 8 fit on the same row, while there seem to be 12 columns if I only put one label per row, but the last 2 columns on the right are not visible:
for n in range(15):
grid_panel.add_component(Label(text=str(n)), row='x', col_xs=n, width_xs=1)
for n in range(15):
grid_panel.add_component(Label(text=str(n)), row=f'r{n}', col_xs=n, width_xs=1)
At this point I need to abandon the GridPanel
. It’s too unpredictable.
I will try with an XYPanel
.