0

[6.0] Listbox with multiple

asked 2012-05-02 00:44:22 +0800

satan87 gravatar image satan87
255

Hello

in ZK 6.0, how can i display a listbox, with checkmark=true, multiple=true and all value selected by default ?

I got that but it's not working

SimpleListModel<TypeEvent> slm = new SimpleListModel<TypeEvent>( TypeEventImpl.getInstance().getTypesEvent() );
			
//We load types
slm.setMultiple(true);
lstType.setCheckmark(true);
			
lstType.setModel( slm );
lstType.setItemRenderer(ter);
						
for(int i = 0 ; i < slm.getSize() ; i++){
lstType.getItemAtIndex(i).setSelected(true);
}


Thanks

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2012-05-02 16:50:53 +0800

satan87 gravatar image satan87
255

any idea ?

thanks

link publish delete flag offensive edit

answered 2012-05-02 18:08:24 +0800

Matze2 gravatar image Matze2
773 7

updated 2012-05-02 18:08:59 +0800

I am not an expert in Java only approaches, but I think you need to maintain your selection state in the model, not in the UI objects - in your case Listitem.

link publish delete flag offensive edit

answered 2012-05-02 18:25:07 +0800

satan87 gravatar image satan87
255

make sense, any idea how to do it ?

link publish delete flag offensive edit

answered 2012-05-02 23:22:41 +0800

satan87 gravatar image satan87
255

Hello

I find a way to do it

slm = new SimpleListModel<TypeEvent>( TypeEventImpl.getInstance().getTypesEvent() );
			
			//We load types
			slm.setMultiple(true);
			for(int i = 0 ; i < slm.getSize() ; i++)
				slm.addToSelection( (TypeEvent)slm.getElementAt(i));

I'm not sure it's the best way, but it's working

Nico

link publish delete flag offensive edit

answered 2012-05-02 23:39:43 +0800

Matze2 gravatar image Matze2
773 7

Just from looking at the code, there is also a setSelection(...) method in SimpleListModel().

link publish delete flag offensive edit

answered 2012-05-02 23:53:10 +0800

satan87 gravatar image satan87
255

slm.setSelection(TypeEventImpl.getInstance().getTypesEvent());

That is working too, but the request is made twice in db.

link publish delete flag offensive edit

answered 2012-05-03 06:31:55 +0800

Matze2 gravatar image Matze2
773 7

I think you can use the same result for both entries (maybe even "must", if you do not have a customized "equals/hashCode" implementation).

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: 2012-05-02 00:44:22 +0800

Seen: 138 times

Last updated: May 03 '12

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