Biglistbox Renderer"

From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} The implementation of a custom renderer for a Biglistbox (<javadoc type="interface">org.zkoss.zkmax.zul.MatrixRenderer</javadoc>) is straight...")
 
m ((via JWB))
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
<source lang="java">
 
<source lang="java">
public class MatrixRenderer<List<String>>{
+
public class DataRenderer implements org.zkoss.zkmax.zul.MatrixRenderer<List<String>> {
 
   
 
   
 
     @Override
 
     @Override
Line 26: Line 26:
 
</source>
 
</source>
  
Then, if we have a list model (<javadoc>org.zkoss.zkmax.zul.MatrixModel</javadoc>) called <tt>data</tt>, and an instance of a custom renderer called <tt>dataRenderer</tt>, then we can put them together in a ZUML document as follows:
+
Then, if we have a list model (<javadoc>org.zkoss.zkmax.zul.MatrixModel</javadoc>) called <code>data</code>, and an instance of a custom renderer called <code>dataRenderer</code>, then we can put them together in a ZUML document as follows:
  
 
<source lang="xml">
 
<source lang="xml">
Line 38: Line 38:
  
 
=Version History=
 
=Version History=
{{LastUpdated}}
+
 
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-

Latest revision as of 07:34, 8 July 2022


Biglistbox Renderer


The implementation of a custom renderer for a Biglistbox (MatrixRenderer) is straightforward[1]:

public class DataRenderer implements org.zkoss.zkmax.zul.MatrixRenderer<List<String>> {
 
    @Override
    public String renderCell(Component owner, List<String> data,
            int rowIndex, int colIndex) throws Exception {
        String d = data.get(colIndex);
        d = d.replace("ZK", "<span class='red' title='ZK'>ZK</span>")
                .replace("Hello", "<span class='blue' title='Hello'>Hello</span>");
        return "<div class='images_" + (colIndex%28) + "' title='x=" +
        colIndex + ",y=" + rowIndex + "'>" + d + "</div>";
    }
 
    @Override
    public String renderHeader(Component owner, List<String> data,
            int rowIndex, int colIndex) throws Exception {
        return "<div class='images_" + (colIndex % 28) + "' title='"
                + images[colIndex % 28] + "'>" + data.get(colIndex)
                + "</div>";
    }
}

Then, if we have a list model (MatrixModel) called data, and an instance of a custom renderer called dataRenderer, then we can put them together in a ZUML document as follows:

<biglistbox model="${data}" matrixRenderer="${dataRenderer}"/>

  1. For the concept about component, model and renderer, please refer to the Model-driven Display section.

Version History

Version Date Content
6.0.1 March 2012 Biglistbox was introduced.



Last Update : 2022/07/08

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