Skip to content
Advertisement

How to clear ListBox? (ZK)

I have very simple question. I amazed, that couldn’t find answer. How can I make total clearing of ListBox (org.zkoss.zul.ListBox) in ZK Framework?

Advertisement

Answer

Code below clears the Listbox, but maybe causes problems, if a model is used :

lb.getItems().clear();

Code below clears the selection :

lb.clearSelection();

Code below sets a new model, deletes the old one and all items. The Listbox will be empty if the model is empty

lb.setModel(model);

If you like to get a new set of Items, the last one should be the best.
If you have a List of them use :

lb.setModel(new ListModelList<>(myList)); 
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement