Vbox"

From Documentation
Line 37: Line 37:
 
[[Image:ZKComRef_Vbox_Simple_Example_align_pack.PNG]]  
 
[[Image:ZKComRef_Vbox_Simple_Example_align_pack.PNG]]  
  
<source lang="xml" >
+
<source lang="xml" high="23">
<zk xmlns:n="http://www.zkoss.org/2005/zk/native">
+
<zk xmlns:n="native">
<zscript><![CDATA[
+
    <style content=".box { border: 1px solid lightgrey; }"/>
Map map = new LinkedHashMap();
+
    <custom-attributes
String[] packs = new String[]{"", "start", "center", "end"};
+
        packs="${['', 'start', 'center', 'end']}"
String[] aligns = new String[]{"", "stretch", "start", "center", "end"};
+
        aligns="${['', 'stretch', 'start', 'center', 'end']}"
+
    />
for (int i = 0; i < aligns.length; i++) {
+
 
String align = aligns[i];
+
    <vlayout>
List list = new ArrayList();
+
        <hlayout height="70px" width="600px">
for (int j = 0; j < packs.length; j++) {
+
            <div hflex="1" vflex="1" sclass="box">
list.add(packs[j]);
+
              <n:h3>pack / align</n:h3>
}
+
            </div>
map.put(align, list);
+
            <div forEach="${aligns}" hflex="1" vflex="1" sclass="box">
}
+
              <n:h3>${each}</n:h3>
+
            </div>
]]></zscript>
+
        </hlayout>
<tablelayout columns="6">
+
        <hlayout forEach="${packs}" height="150px" width="600px">
<tablechildren >
+
            <custom-attributes pack="${each}"/>  
<panel border="normal" height="150px" width="100px"  
+
            <div hflex="1" vflex="1" sclass="box">
forEach='"pack / align", "", "start", "center", "end"'>
+
              <n:h3>${pack}</n:h3>
<panelchildren>
+
            </div>
<n:h3>${each}</n:h3>
+
         
</panelchildren>
+
            <vbox forEach="${aligns}" align="${each}" pack="${pack}" hflex="1" vflex="1" sclass="box">
</panel>
+
                <button label="1" />
</tablechildren>
+
                <button label="2" />
<tablechildren forEach="${map}">
+
                <button label="3" />
<custom-attributes key="${each.key}"/>  
+
            </vbox>
<panel border="normal" height="150px" width="100px">
+
        </hlayout>
<panelchildren>
+
    </vlayout>
<n:h3>${key}</n:h3>
 
</panelchildren>
 
</panel>
 
<panel border="normal" height="150px" width="100px" forEach="${each.value}" >
 
<panelchildren>
 
<vbox align="${key}" pack="${each}" height="90%" width="100%">
 
<button label="1" />
 
<button label="2" />
 
<button label="3" />
 
</vbox>
 
</panelchildren>
 
</panel>
 
</tablechildren>
 
</tablelayout>
 
 
</zk>
 
</zk>
 
</source>
 
</source>

Revision as of 07:06, 4 January 2019

Vbox

Employment/Purpose

The vbox component is used to create a vertically oriented box. Added components will be placed underneath each other in a column.

Notice that hbox and vbox are designed to provode more sophisticated layout, such as splitter, alignment and packing. If you need only the layout feature, it is suggest to use Hlayout and Vlayout instead, since the performance is much better (due to the use of HTML DIV instead of TABLE).

Example

ZKComRef Vbox Simple Example.PNG

<zk>
     <vbox>
         <button label="Button 1"/>
         <button label="Button 2"/>
     </vbox>
     <hbox>
         <button label="Button 3"/>
         <button label="Button 4"/>
     </hbox>
</zk>

Properties

  • Inherited Properties: Box

Align and Pack

ZKComRef Vbox Simple Example align pack.PNG

<zk xmlns:n="native">
    <style content=".box { border: 1px solid lightgrey; }"/>
    <custom-attributes 
        packs="${['', 'start', 'center', 'end']}"
        aligns="${['', 'stretch', 'start', 'center', 'end']}"
    />

    <vlayout>
        <hlayout height="70px" width="600px">
            <div hflex="1" vflex="1" sclass="box">
              <n:h3>pack / align</n:h3>
            </div>
            <div forEach="${aligns}" hflex="1" vflex="1" sclass="box">
              <n:h3>${each}</n:h3>
            </div>
        </hlayout>
        <hlayout forEach="${packs}" height="150px" width="600px">
            <custom-attributes pack="${each}"/> 
            <div hflex="1" vflex="1" sclass="box">
              <n:h3>${pack}</n:h3>
            </div>
          
            <vbox forEach="${aligns}" align="${each}" pack="${pack}" hflex="1" vflex="1" sclass="box">
                <button label="1" />
                <button label="2" />
                <button label="3" />
            </vbox>
        </hlayout>
    </vlayout>
</zk>
[Since 5.0.0]

Cell Component

In ZK5, we have introduced a new component named Cell which can be embedded into a Grid or Box (Hbox and Vbox) to fully control the layout and the style. You can now use the rowspan or the colspan property to layout your Grid, for example a content cell can now cross over multiple rows. The code below demonstrates how to do this:

<vbox>
    <cell sclass="years">
        ...
    </cell>
</vbox>
[Since 5.0.0]

Limitation

Box component is consisted by Table element. Therefore, when put Input element like Textbox, Combobox inside Box component, specify width and height to Box component will be ignored when browser try to render table element.

For example,

<hbox height="200px" width="200px" style="border: 1px solid red">
    <textbox hflex="1" value="1" />
    <textbox hflex="1" value="1" />
</hbox>

You will see the Box width exceed 200px. Also check the sample with pure HTML in jsfiddle.

Supported Events

Name
Event Type
None None
  • Inherited Supported Events: Box

Supported Children

*ALL

Use Cases

Version Description Example Location
     

Version History

Last Update : 2019/01/04


Version Date Content
     



Last Update : 2019/01/04

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.