0

Select single Listcell in a listbox

asked 2009-09-02 08:53:24 +0800

SerFingolfin gravatar image SerFingolfin
70 2

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

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2009-09-03 15:03:12 +0800

SerFingolfin gravatar image SerFingolfin
70 2

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.

link publish delete flag offensive edit

answered 2009-09-03 11:18:36 +0800

baskaraninfo gravatar image baskaraninfo
536 2 2 9

@SerFingolfin

You can try grid component, to have an individual cell selection in a row.

link publish delete flag offensive edit

answered 2009-09-03 10:19:18 +0800

SerFingolfin gravatar image SerFingolfin
70 2

updated 2009-09-03 10:19:26 +0800

Unfortunately ZK Spreadsheet offers a way to embed only an existing xls file into a web page.
But i don't need that.

link publish delete flag offensive edit

answered 2009-09-02 14:02:05 +0800

SerFingolfin gravatar image SerFingolfin
70 2

Thank you so much! I'll try it.

link publish delete flag offensive edit

answered 2009-09-02 13:27:26 +0800

YamilBracho gravatar image YamilBracho
1722 2

Maybe you can use ZK Spreadsheet (http://www.zkoss.org/product/zkspreadsheet.dsp)

link publish delete flag offensive edit

answered 2009-09-02 12:56:28 +0800

SerFingolfin gravatar image SerFingolfin
70 2

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

link publish delete flag offensive edit

answered 2009-09-02 09:44:16 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-09-02 09:49:21 +0800

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

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

Follow

RSS

Stats

Asked: 2009-09-02 08:53:24 +0800

Seen: 343 times

Last updated: Sep 03 '09

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