Auxheader hide problem in grid

asked 2014-08-27 14:26:26 +0800

Ashutosh gravatar image Ashutosh

updated 2014-08-28 07:55:56 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8

I am using grid to show data of employee. I added auxheader to add filter to each column. I added property to columns tag - menupopup="auto". It is showing menu to each column.But when i hide some column from that menu, respective auxheader are still present in grid and hence mismatch occurs. Is their any way to hide respective auxheader with column or any another tag that i can use instead of auxheader ?? Thanks for help in advance.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-28 09:01:38 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Ashutosh,

In order to accomplish your task, you have to set unique id's to the columns, and filters. Furthermore you have to set forward events for the menu items.

I have prepared for you a sample code below so you can see the logic:

-- index.zul


 <menupopup id="editPopup">

    <menuitem id="subjectMenuItem" label="Subject" forward="onShowColumn(subject)" />
    <menuitem label="Received" forward="onShowColumn(received)" />  
    <menuitem label="Size" forward="onShowColumn(size)"/>
    <menuseparator />

<grid id="inboxGrid" width="600px"  height="250px" 
    emptyMessage="Nothing in Inbox.">

            <textbox id="subjectFilter" visible="true"></textbox>

    <columns menupopup="editPopup">
        <column id="subjectColumn" label="Subject" visible="true"/>
        <column width="50px" label="Received"  />
        <column width="80px" label="Size" />

<!-- refresh content every 5 seconds -->
<timer id="timer" delay="2000" repeats="true" />


-- TestComposer:

package pkg$;

import org.zkoss.zk.ui.event.*;
import org.zkoss.zul.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Grid;
import org.zkoss.zul.ListModelList;

public class TestComposer extends GenericForwardComposer{

    private static final long serialVersionUID = 1L;
    private Grid inboxGrid;

    private Column subjectColumn;

    private Textbox subjectFilter;

    private boolean subjectVisible = true;

  public void doAfterCompose(Component comp) throws Exception {

    inboxGrid.setModel(new ListModelList(getData()));

  public void onTimer$timer(Event e){
    //inboxGrid.setModel(new ListModelList(getUpdatedData()));

  public void onShowColumn(ForwardEvent event) throws Exception { 
    String columnName = (String) event.getData();

    if (columnName.equals("subject")) {
        subjectVisible = !subjectVisible;


  /* simply return a small model here , you could read data from database for your own implementation.*/
  private List<String[]> getData(){
    ArrayList<String[]> list= new ArrayList<String[]>();

    list.add(new String[]{"Test Mail1","TonyQ", "10k"});
    list.add(new String[]{"Test Mail12","Ryan", "100k"});
    list.add(new String[]{"Test Mail13","Simon", "15k"});
    list.add(new String[]{"Test Mail14","Jimmy", "5k"});    
    return list;

  private List<String[]> getUpdatedData(){
    ArrayList<String[]> list= new ArrayList<String[]>();

    list.add(new String[]{"Test Mail1-updated-"+new Date().toString(),"TonyQ", ((int ) ( Math.random() *100 )) + "k"});
    list.add(new String[]{"Test Mail12-updated"+new Date().toString(),"Ryan", ((int ) ( Math.random() *100 )) + "k"});
    list.add(new String[]{"Test Mail13-updated"+new Date().toString(),"Simon", ((int ) ( Math.random() *100 )) + "k"});
    list.add(new String[]{"Test Mail14-updated"+new Date().toString(),"Jimmy", ((int ) ( Math.random() *100 )) + "k"});    

    list.add(new String[]{"Test Mail15-updated"+new Date().toString(),"Hi", ((int ) ( Math.random() *100 )) + "k"});    

    return list;

public boolean isSubjectVisible() {
    return subjectVisible;

public void setSubjectVisible(boolean subjectVisible) {
    this.subjectVisible = subjectVisible;

public Textbox getSubjectFilter() {
    return subjectFilter;

public void setSubjectFilter(Textbox subjectFilter) {
    this.subjectFilter = subjectFilter;

public Column getSubjectColumn() {
    return subjectColumn;

public void setSubjectColumn(Column subjectColumn) {
    this.subjectColumn = subjectColumn;


-- MyRowRenderer

package pkg$;

import org.zkoss.zul.Label;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;

public class MyRowRenderer implements RowRenderer {

    public void render(Row row, Object data, int index) throws Exception {
         String[] ary = (String[]) data;
            new Label(ary[0]).setParent(row);
            new Label(ary[1]).setParent(row);
            new Label(ary[2]).setParent(row);

Best Regards,


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2014-08-27 14:26:26 +0800

Seen: 33 times

Last updated: Aug 28 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More