Grid

Components: grid, columns, column, rows and row.

A grid contains components that are aligned in rows like tables. Inside a grid, you declare two things, the columns, that define the header and column attributes, and the rows, that provide the content. To declare a set of rows, use the rows component, which should be a child element of grid. Inside that you should add row components, which are used for each row. Inside the row element, you should place the content that you want inside that row. Each child is a column of the specific row. Similarly, the columns are declared with the columns component, which should be placed as a child element of the grid. Unlike row is used to hold the content of each row, column declares the common attributes of each column, such as the width and alignment, and and optional headers, i.e., label and/or image.

<window title="Grid Demo" border="normal" width="360px">
    <zscript>    
    class Comp implements Comparator {    
        private boolean _asc;        
        public Comp(boolean asc) {        
            _asc = asc;            
        }        
        public int compare(Object o1, Object o2) {        
            String s1 = o1.getChildren().get(0).getValue(),            
                s2 = o2.getChildren().get(0).getValue();                
            int v = s1.compareTo(s2);            
            return _asc ? v: -v;            
        }        
    }    
    Comp asc = new Comp(true), dsc = new Comp(false);    
    </zscript>    
    <grid>    
        <columns sizable="true">        
            <column label="Type" sortAscending="&#36;{asc}" sortDescending="&#36;{dsc}"/>            
            <column label="Content"/>            
        </columns>        
        <rows>        
            <row>            
                <label value="File:"/>                
                <textbox width="99%"/>                
            </row>            
            <row>            
                <label value="Type:"/>                
                <hbox>                
                    <listbox rows="1" mold="select">                    
                        <listitem label="Java Files,(*.java)"/>                        
                        <listitem label="All Files,(*.*)"/>                        
                    </listbox>                    
                    <button label="Browse..."/>                    
                </hbox>                
            </row>            
            <row>            
                <label value="Options:"/>                
                <textbox rows="3" width="99%"/>                
            </row>            
        </rows>        
    </grid>    
</window>

Class Name

org.zkoss.zul.Grid

Supported Child Components

Columns Rows

Supported Events

Name

Event Type

onPaging

org.zkoss.zul.event.PagingEvent

Description: Notifies one of the pages of a multi-page component is

selected by the user.

Properties

Property

Description

Data Type

Default Value

align

Sets the horizontal alignment of the whole grid.

Val ue: left|center|right

java.lang.String

<null>

mod el

Sets the list model associated with this grid.

org.zkoss.zul.ListModel

<null>

pageSize

Sets the page size, aka., the number rows per page.

Note: Available only the paging mold

int

<null>

paginal

org.zkoss.zul.ext.Paginal

<null>

pre loadSize

Sets the number of rows to preload when receiving the rendering request from the client.

int

7

rowrenderer

Sets the renderer which is used to render each row if getModel() is not null.

org .zkoss.zul.RowRenderer

<null>

Methods

Name

Description

Return Data Type

clone()

java.lang.Object

getCell(int, int)

Returns the specified cell, or null if not available.

org.zkoss.zk.ui.Component

getColumns()

Returns the columns.

org .zkoss.zul.Columns

getFoot()

Returns the foot.

org .zkoss.zul.Foot

getOuterAttrs()

java.lang.String

getPaging()

Returns the child paging controller that is created automatically, or null if mold is not "paging", or the controller is specified externally by setPaginal(org.zkoss.zul.ext.Paginal).

org .zkoss.zul.Paging

getRows()

Returns the rows.

org .zkoss.zul.Rows

ins ertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)

boo lean

onInitRender()

Handles a private event, onInitRender.

void

onPaging()

Called when the onPaging event is received (from getPaginal()).

void

removeChild(org.zkoss.zk.ui.Component)

boo lean

renderAll()

Renders all Row if not loaded yet, with getRowRenderer().

void

renderItems(java.util.Set)

void

renderRow(Row)

Renders the specified Row if not loaded yet, with getRowRenderer().

void

renderRows(java.util.Set)

Renders a set of specified rows.

void

setMold(ListModel)

void

setRowRenderer(java.lang.String)

Sets the renderer by use of a class name.

void

Inherited From