-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi everybody.
Is it possible to select a single Listcell in a listbox?
Normally you see the entire row selected when you move the mouse over a listcell...
Think in objects!
What you get as a row from the listBox represents in most cases an object from the
underlaying Data.
--> the single ListCell represents a property of the domain object.
@SuppressWarnings("unchecked") public void onDoubleClicked(Event event) throws Exception { // get the selected customer object from the listbox Listitem item = customerListbox.getSelectedItem(); if (item != null) { // Cast to the represented Domain Object Customer customer = (Customer) item.getAttribute("data"); ... } public class CustomerItemRenderer implements ListitemRenderer, Serializable { private static final long serialVersionUID = 1L; private transient final static Logger logger = Logger.getLogger(CustomerItemRenderer.class); @Override public void render(Listitem item, Object data) throws Exception { Customer customer = (Customer) data; Listcell lc = new Listcell(customer.getCustomerName()); lc.setParent(item); lc = new Listcell(customer.getCustomerNr()); lc.setParent(item); item.setAttribute("data", data); // ComponentsCtrl.applyForward(item, "onClick=onClicked"); ComponentsCtrl.applyForward(item, "onDoubleClick=onDoubleClicked"); } }
regards
Stephan
Thanks, but i was wondering if there is the possibility to select a single cell
in a row with the mouse because when i move in a cell of my listbox the entire
row becomes highlighted.
Your code appears to set "onDoubleClicked" event.
But i wish to display a listbox as a grid with every single cell highlighted (like excel).
Thanks anyway
Maybe you can use ZK Spreadsheet (http://www.zkoss.org/product/zkspreadsheet.dsp)
Thank you so much! I'll try it.
Unfortunately ZK Spreadsheet offers a way to embed only an existing xls file into a web page.
But i don't need that.
@SerFingolfin
You can try grid component, to have an individual cell selection in a row.
I solved with a java-generated grid, like this :
Columns aGridColumns = new Columns(); aGridColumns.setId(cGridModuleViewColumnsName); for (int aCurrentColumn = 0;aCurrentColumn<_module.getColumnsnumber();aCurrentColumn++) aGridColumns.appendChild(new Column(String.valueOf(aCurrentColumn), cGridModuleViewColumnsName)); aGridColumns.setParent(this.getFellow(cGridModuleViewName)); Cell[] aCells = aCellsCollection.toArray(new Cell[0]); Rows aRows = new Rows(); for (int aCurrentRow=_module.getRowsnumber() * 2-1;aCurrentRow>=0;aCurrentRow--) { Row aRow = new Row(); for (int aCurrentColumn = 0;aCurrentColumn<_module.getColumnsnumber();aCurrentColumn++) { final Cell aCurrentCell = aCells[aCurrentRow * _module.getColumnsnumber() + aCurrentColumn]; Button aButton = new Button((aCurrentCell.getContentid() == null ? " " : aCurrentCell.getContentid())); aRow.appendChild(aButton); } aRows.appendChild(aRow); } this.getFellow(cGridModuleViewName).appendChild(aRows);
I placed a button inside : that's not so nice but it works.
Thanks to everybody.
Asked: 2009-09-02 08:53:24 +0800
Seen: 343 times
Last updated: Sep 03 '09