GWT列表框多选 [英] GWT Listbox Multi Select
问题描述
我需要添加一个允许用户选择多个值的listbox / combobox。
我知道GWT API中已经有一个
ListBox 使用isMultipleSelect()设置为true的
。但我没有得到任何直接的方式从列表框中获取所有选定的reocrds。
有些谷歌教程是sugeesting实现 ChangeHandler
的 onChange
方法。
我认为应该有其他方法。 b
$ b
任何指针都会被赞赏。
创建您自己的小型子类<$ c
public LinkedList< Integer> $ c> ListBox
getSelectedItems(){
LinkedList< Integer> selectedItems = new LinkedList< Integer>();
for(int i = 0; i< getItemCount(); i ++){
if(isItemSelected(i)){
selectedItems.add(i);
}
}
返回selectedItems;
}
GWT API不提供直接的方法。
I need to add a listbox / combobox which allows the user to choose several values.
I know there is one already available in the GWT API ListBox with isMultipleSelect() set to true. But I am not getting any direct way to get all selected reocrds from list box.
Some tutorials on google are sugeesting implement ChangeHandler
's onChange
method.
I think there should be some other way.
Any pointers would be appreciated.
Create your own small subclass of ListBox
offering a method like
public LinkedList<Integer> getSelectedItems() {
LinkedList<Integer> selectedItems = new LinkedList<Integer>();
for (int i = 0; i < getItemCount(); i++) {
if (isItemSelected(i)) {
selectedItems.add(i);
}
}
return selectedItems;
}
The GWT API does not offer a direct way.
这篇关于GWT列表框多选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!