1

我想要做的就是每次使用 CheckBoxSelectionModel 选中或取消选中 Grid 中的项目时捕获一个事件。使用 SelectionHandler 可以轻松选中/选中的部分。我没有看到任何在多选模式下触发取消选择事件的东西。我有一个包含 1000 个左右项目的网格,我让用户多选项目以在地图上进行跟踪。It's not giong to perform well to scan the entire model whenever a selection changes so I'm wondering how to handle this.

4

1 回答 1

4

你是对的。SelectionHandler 只会提供选中/选中状态。我有类似的要求,我通过覆盖 CheckBoxSelectionModel 的 onSelectChange() 方法解决了这个问题。

这是供您参考的示例代码。

IdentityValueProvider<VO> identity = new IdentityValueProvider<VO>();
CheckBoxSelectionModel<VO> sm = new CheckBoxSelectionModel<VO>(identity) {

    protected void onSelectChange(VO model, boolean select) {

        super.onSelectChange(model, select);
        if (select) {
            // Do something on select ...
        } else {
            // Do something on deselect ...
        }
    };
};

希望这可以帮助。

于 2013-01-10T12:27:02.973 回答