4

I want a layout of <p:panelGrid> (or <h:panelGrid>) as shown in the following snap shot.

enter image description here

The following code,

<p:panelGrid style="width: 100%;">
    <p:row>
        <p:column rowspan="9">a</p:column>
        <p:column rowspan="7">b</p:column>
        <p:column>c</p:column>
    </p:row>

    <p:row><p:column>d</p:column></p:row>
    <p:row><p:column>e</p:column></p:row>
    <p:row><p:column>f</p:column></p:row>
    <p:row><p:column>g</p:column></p:row>
    <p:row><p:column>h</p:column></p:row>
    <p:row><p:column>i</p:column></p:row>
    <p:row><p:column>j</p:column></p:row>
    <p:row><p:column>k</p:column></p:row>
</p:panelGrid>

shows the layout as shown in the following snap shot.

enter image description here

How can I achieve the layout as shown in first snap shot?

Tiny
  • 27,221
  • 105
  • 339
  • 599

1 Answers1

12
        <p:panelGrid style="width: 100%;">
            <p:row>
                <p:column rowspan="7">a</p:column>
                <p:column rowspan="5">b</p:column>
                <p:column>e</p:column>
            </p:row>

            <p:row>
                <p:column>f</p:column>
            </p:row>

            <p:row>
                <p:column>g</p:column>
            </p:row>

            <p:row>
                <p:column>h</p:column>
            </p:row>

            <p:row>
                <p:column>i</p:column>
            </p:row>

            <p:row>
                <p:column>c</p:column>
                <p:column>j</p:column>
            </p:row>

            <p:row>
                <p:column>d</p:column>
                <p:column>k</p:column>
            </p:row>

        </p:panelGrid>

Explanation:

enter image description here

Each row will try to place itself under the previous row where there is space for it (where a column is not spanning over multiple rows).

So after the first row: the next rows will be placed in the following positions:

enter image description here

But since you want the 6th and 7th row to have 2 columns, you need to add a second column to them.

Hopefully this clears it up a little.

Emil Kaminski
  • 1,886
  • 2
  • 16
  • 26
  • This works but I don't understand the logic behind it :) – Tiny Jun 12 '14 at 06:39
  • 1
    Glad i could help, the PanelGrid construction is a little tricky and i took me some time to get it as well... See my updated answer for explanation – Emil Kaminski Jun 12 '14 at 07:56