Grid selection

sankaralingam
33 1

Team,

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="ImagePreview"/>
</columns>
<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}"/>
<button id="image" label="Image Preview" left="false" width="110px" height="25px"/>
</row>
</rows>
</grid>

Sankar

delete retag edit

5 Replies

sankaralingam
33 1

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

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.

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??

Sankar,

526 2 2 9

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.

sanderaiaots
3

Hi!

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})"/>

[hide preview]