0

Grouping in Grid!

asked 2013-04-03 04:45:56 +0800

jmyneni gravatar image jmyneni
5 1

Hi,

I am trying to loop through database results and render a grid that has grouping on a page. The group label should be a term and the group rows should display all the possible uses of this term. The possible uses of a term are stored as pipe delimited text in the database. This is my Java code:

public void populateGlossary() { Rows rows = new Rows();
glossary.appendChild(rows);

 Group cGrp = new Group("GlossaryTerm1:");
 cGrp.setVisible(true);
 cGrp.setOpen(true);
 glossary.getRows().appendChild(cGrp);

 Row cRow = new Row();
 cRow.appendChild(new Label(""));
 cRow.appendChild(new Label("Explanation of term1"));
 glossary.getRows().appendChild(cRow);

 List glossaryResults = executeNamedQuery("getGlossary", null, null);

 for (int i=0; i < glossaryResults.size(); i++) {
      Object[] dataObj = (Object[]) glossaryResults.get(i);

      Group grp = new Group(dataObj[0].toString());
      grp.setVisible(true);
      grp.setOpen(true);
      glossary.getRows().appendChild(grp);

      String[] codeUses = dataObj[1].toString().split("\\|");
      for (int j=0;j<codeUses.length;j++) {
           Row row = new Row();
           row.appendChild(new Label(""));
           row.appendChild(new Label(codeUses[j].toString()));
           glossary.getRows().appendChild(row);
      }
 }

}

My jsp page is: <z:grid id="glossary" mold="paging" pagesize="50" pagingposition="both" emptymessage="There is currently no glossary available."> <z:columns sizable="true"> <z:column label="Code" width="30%"/> <z:column label="Code Use" width="70%" align="left"/> </z:columns> </z:grid>

The grid displays fine...but there is no Expand/Collapse button next to the Group Label. The Group looks like a row. What I am doing wrong?

Thank you for your time.

Regards, Jyothi

delete flag offensive retag edit

Comments

Thank you Steva77. Master Detail when implemented in Java needs OnOpen Event to create detail components, right? I was looking for some simpler implementation of hide/show detail. Can Grouping be implemented in Java?

Thanks again!

jmyneni ( 2013-04-03 13:52:05 +0800 )edit

Actually, I never implemented the master-detail feature programmatically, but I assume is rather similar to your iterative approach, unless you want to create the detail component on the fly when you fire the OnOpenEvent...

No ready-to-use solution, sorry...

Steva77 ( 2013-04-03 14:31:00 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-04-03 10:22:57 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

Any chance to use master-detail feature?

See http://www.zkoss.org/zkdemo/grid/master_detail

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

Follow
1 follower

RSS

Stats

Asked: 2013-04-03 04:45:56 +0800

Seen: 38 times

Last updated: Apr 03 '13

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