0

Selected Column in ListBox

asked 2010-02-19 14:16:38 +0800

meilynlgg gravatar image meilynlgg
43 1 1 2

Hi all,

I need your help about this: as knowing the selected column by clicking in a listbox.
There is a any method getSelectedColumn() ?? or something like?

Thank's a lot..

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-02-22 12:53:43 +0800

meilynlgg gravatar image meilynlgg
43 1 1 2

Hi as1225,

Thank's for your help!

Really was very helpful.... I did something similar but using addListener.

:)

link publish delete flag offensive edit

answered 2010-02-21 22:38:23 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi, meilynlgg
I write a sample

<zk>
	<zscript><![CDATA[
		 void showColumn(Listcell listcell){
			 Listitem item = listbox.getSelectedItem();
			 int index = item.getChildren().indexOf(listcell);
			 Listheader listheader = (Listheader)listbox.getListhead().getChildren().get(index);
			 alert(listheader.getLabel());
		 }
	]]></zscript>
	<listbox id="listbox" width="200px">
		<listhead>
			<listheader label="col1" />
			<listheader label="col2" />
		</listhead>
		<listitem>
			<listcell label="a1" onClick="showColumn(self)"/>
			<listcell label="a2" onClick="showColumn(self)"/>
		</listitem>
		<listitem>
			<listcell label="b1" onClick="showColumn(self)" />
			<listcell label="b2" onClick="showColumn(self)"/>
		</listitem>
	</listbox>
</zk>

It works on ZK 3.6.X
it will happen NPE on ZK 5.X
because this bug
we will fix it

link publish delete flag offensive edit

answered 2010-02-21 09:41:56 +0800

kesavkolla gravatar image kesavkolla
180 3

listbox doesn't have selected column you can only get selected row. If you need selected column you have to have a control (button, image etc..) and let the user click on the control. That will give you an idea on which column they clicked.

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: 2010-02-19 14:16:38 +0800

Seen: 545 times

Last updated: Feb 22 '10

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