Grid Renderer"

From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} When a grid (<javadoc>org.zkoss.zul.Grid</javadoc>) is assigned with a model, a default renderer is assigned too<ref>For the concept about co...")
 
m ((via JWB))
Line 27: Line 27:
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-

Revision as of 08:17, 11 January 2022

When a grid (Grid) is assigned with a model, a default renderer is assigned too[1]. The default renderer will assume that each row has only one column, and it converts the data into a string directly[2]. If you want to display multiple columns or retrieve a particular field of the data, you have to implement RowRenderer to handle the rendering.

For example,

public class FoodGroupRenderer implements RowRenderer, java.io.Serializable {
    public void render(Row row, Object obj, int index) {
        if (row instanceof Group) {
            row.appendChild(new Label(obj.toString()));
        } else {
            User user = (User) obj;
            row.appendChild(new Label(user.getName()));
            row.appendChild(new Label(user.getDescription()));
            row.appendChild(new Label(user.getDomain()));
        }
    }
}

  1. For the concept about component, model and renderer, please refer to the Model-driven Display section.
  2. If the grid is assigned a template called model, then the template will be used to render the grid. For more information, please refer to the Grid Template section.

Version History

Last Update : 2022/01/11


Version Date Content
6.0.0 February 2012 The index argument was introduced.



Last Update : 2022/01/11

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