Grid selection

asked 2009-10-09 10:49:02 +0800

sankaralingam gravatar image sankaralingam
33 1


I have a grid in which a data model is associated.. And i am adding a button in every row(at last column). When i click the row i want to fetch the row information and show a image retrieving it from the database..

I dont know how to achieve.. Can anyone help me out..please..

Grid zul: (where the model docs is a vector, in this grid i have a button which i associated a event listener... How can i fetch the row informationn)... I have created a variable in my bean class but dont know how to set when the button is clicked.. help me out ...

<grid id="docTable" fixedLayout="true" mold="paging" pageSize="4" model="@{docs}" width="100%" forward="onMouseOver">
<columns id="column" >
<column label="DocID" width="10%" sortDirection="ascending" sortAscending="${asc}" sortDescending="${dsc}"/>
<column label="DocType" sortDirection="ascending" sortAscending="${asc}" sortDescending="${dsc}"/>
<column label="DocName" sortDirection="ascending" sortAscending="${asc}" sortDescending="${dsc}"/>
<column label="Size" width="10%"/>
<column label="Comments" width="20%"/>
<column label="DownloadThedoc" width="20%"/>
<column label="ImagePreview"/>
<rows id="docRow">
<row self="@{ each='clientDoc'}" value="@{clientDoc.setSelected}">
<label value="@{clientDoc.docID}"/>
<label value="@{clientDoc.docType}"/>
<label value="@{clientDoc.docName}"/>
<label value="@{clientDoc.docSize}"/>
<label value="@{clientDoc.comments}"/>
<label value="@{clientDoc.downloadTheDoc}"/>
<button id="image" label="Image Preview" left="false" width="110px" height="25px"/>


delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-10-09 10:57:59 +0800

sankaralingam gravatar image sankaralingam
33 1

when i call the setSelected its getting setting for all the rows... i dont know how to identify the clicked row...

link publish delete flag offensive edit

answered 2009-10-09 11:54:17 +0800

baskaraninfo gravatar image baskaraninfo
526 2 2 9

Write a grid renderer by implementing RowRenderer and in this you need to maintain the row_id in public void render(Row _row, Object _data) method.

For ex:

private HashMap<Integer, String> rowIdList = new HashMap<Integer, String>();

rowIdList.put(++rowCounter, _row.getId());
component.setAttribute(ROW_ID, _row.getId());

There after you can identify the set of components in a row by getting the components ROW_ID attribute.

link publish delete flag offensive edit

answered 2009-10-10 05:46:22 +0800

sankaralingam gravatar image sankaralingam
33 1

Please can you explain it more:

Wat is this component refer to?

In your code snippet you are setting the ROW_ID and why there is a need for a hashmap??


link publish delete flag offensive edit

answered 2009-10-10 06:05:12 +0800

baskaraninfo gravatar image baskaraninfo
526 2 2 9

updated 2009-10-10 06:05:32 +0800

Component refers to any zul component such as Bandbox, Doublebox, Textbox etc.,

Yes, we have that rowIdList hashmap, to access a particular row afterwards.
For ex: rowIdList.get(0) will fetch the first row's id.

You can even have another hashmap such as below:

HashMap<String, HashMap<String, Object>> compList = new HashMap<String, HashMap<String, Object>>();

To maintain rowid with its appropriate component list.

Thereafter you can access a particular row components by specifying the corresponding rowid.

link publish delete flag offensive edit

answered 2009-10-19 15:40:30 +0800

sanderaiaots gravatar image sanderaiaots


Is there any other simpler solution available?
For example could I use Model data with button or something?
eg. <button label="ClickHere" onClick="onClick(@{clientDoc.docID})"/>

link publish delete flag offensive edit
Your reply
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




Asked: 2009-10-09 10:49:02 +0800

Seen: 242 times

Last updated: Oct 19 '09

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