如何只选择一行,防止在单选模式下取消选择项目 [英] How to select just one row, prevent to unselect item in singleselect mode

查看:37
本文介绍了如何只选择一行,防止在单选模式下取消选择项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单,但我真的没有在这里找到任何解决方案.我有一个表 setSelectable(true)、setMultiselect(false)、setImmediate(true).

My question is very simple but I really didn't find any solution here. I have a Table setSelectable(true), setMultiselect(false), setImmediate(true).

首先单击并使用箭头在表格中移动即可正常工作.但是如果我再次点击已经被选中的行,然后它变为未选中状态.如何预防?我希望始终只选中一行.

It works fine by first click and moving through the table using arrows. But if I click again to the row already having been selected, then it becomes unselected. How to prevent it? I'd like to have kept just one row always selected.

推荐答案

来自 Vaadin Book 此处:

As from the Vaadin Book here:

如果用户单击已选择的项目,则该选择将取消选择并且表格属性将为空值.您可以通过为表设置 setNullSelectionAllowed(false) 来禁用此行为.

If the user clicks on an already selected item, the selection will deselected and the table property will have null value. You can disable this behaviour by setting setNullSelectionAllowed(false) for the table.

所以:

table.setNullSelectionAllowed(false);

这篇关于如何只选择一行,防止在单选模式下取消选择项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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