复选框单元格和可选单元格表格行 [英] Checkbox Cell and Selectable Cell Table rows
问题描述
我有一个与SingleSelectionModel关联的GWT 2.4 DataGrid。网格中的一列是CheckboxCell,但不用于选择,而是为行的基础项目类型设置布尔字段值。我的问题是,当我点击复选框时,首先选中该行,然后我必须再次单击以设置/取消选中该复选框。我希望单击复选框的外选择行,而单击复选框内的 仅设置/取消选中复选框。任何人都可以指导我如何做到这一点的正确方向。我一直回到onBrowserEvent,但我不知道该怎么做。
有几种方法可以做,这取决于你想要做什么。这里有两个想法:- 使用 DefaultSelectionEventManager.CheckboxEventTranslator 将列黑名单
- 截取它逐个单元格与 CellPreviewEvent.Handler ,并通过检查EventTarget(
click.equals(event.getType())
)在DOM级别处理它,然后使用event.stopPropogation()
当EventTarget的输入类型为复选框时
I have a GWT 2.4 DataGrid associated with a SingleSelectionModel. One of the columns in the grid is a CheckboxCell, but it is not used for selection, but to set a boolean field value for the underlying item type of the row. My problem is that when I click on the checkbox, the row is selected first, then I have to click a second time to set/unset the checkbox. I would prefer that clicking outside of the checkbox does row selection, while clicking inside of the checkbox only sets/unsets the checkbox. Can anyone point me in the right direction on how to do this. I keep coming back to onBrowserEvent, but I'm not sure what to try.
There's a couple of approaches you can do, depending on what exactly you want to do it. Here are the two ideas that come to mind:
- Use a DefaultSelectionEventManager.CheckboxEventTranslator to blacklist the column
- Intercept it on a cell by cell basis with CellPreviewEvent.Handler and handle it on the DOM level by checking the EventTarget (
"click".equals(event.getType())
) and then useevent.stopPropogation()
when the EventTarget is of an input type "checkbox"
这篇关于复选框单元格和可选单元格表格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!