简体   繁体   English

如何在网格中隐藏选择复选框?

[英]How to hide selection checkbox in grid?

I have a TreeGrid with selection appearence set to checkbox. 我有一个选择出现设置为复选框的TreeGrid

TreeGrid resultGrid = new TreeGrid();
resultGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);

I want some records to be drawn without these checkboxes(in case record is disabled). 我希望绘制一些没有这些复选框的记录(以防禁用记录)。 I found property showDisabledSelectionCheckbox , which description says: 我发现属性showDisabledSelectionCheckbox ,其描述为:

Should tree nodes show a disabled checkbox instead of a blank space when selectionAppearance:"checkbox" is set on the treegrid, and a node can't be selected ? 如果树节点显示被禁用的复选框而不是一片空白的时候selectionAppearance:“单选按钮”设置上的TreeGrid,和节点不能选择

How I can make the node "unselectable" except setting : 除了设置,我如何使节点“不可选择”:

node.setEnabled(false); node.setEnabled(false);

And how this property(showDisabledSelectionCheckbox) works? 以及此属性(showDisabledSelectionCheckbox)如何工作?

I would start here . 我将从这里开始。 It looks like you can override canEditCell() on the ListGrid itself to keep someone from interacting with the checkbox. 看起来您可以覆盖ListGrid本身上的canEditCell() ,以防止某人与该复选框进行交互。 I haven't been able to find a method to hide the checkbox completely, however. 但是,我还没有找到一种完全隐藏复选框的方法。

Perhaps setting the showDisabledSelectionCheckbox property to false in conjunction with overriding canEditCell() will get you where you're looking to go. 也许将showDisabledSelectionCheckbox属性设置为false并覆盖canEditCell()可以使您到达想要的位置。

TreeGrid has selection property that can be set via TreeGrid具有可以通过设置的选择属性

resultGrid.setSelectionProperty(propertyName);

So setting this property on TreeNodes will define if nodes could be selected. 因此,在TreeNodes上设置此属性将定义是否可以选择节点。 By default one can just use "canSelect" property. 默认情况下,可以只使用“ canSelect”属性。

So this line of code will disable selection of the particular node. 因此,这行代码将禁用特定节点的选择。

treeNode.setAttribute("canSelect", false);

And if selection appearance is set to SelectionAppearance.CHECKBOX , checkboxes won't be drawn near nodes which couldn't be selected. 而且,如果选择外观设置为SelectionAppearance.CHECKBOX则不会在无法选择的节点附近绘制复选框。 This is the only way I've found. 这是我找到的唯一方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM