GWT列表框多选 [英] GWT Listbox Multi Select

查看:90
本文介绍了GWT列表框多选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加一个允许用户选择多个值的listbox / combobox。



我知道GWT API中已经有一个
ListBox 。但我没有得到任何直接的方式从列表框中获取所有选定的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 onChangemethod.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆