简体   繁体   English

如何仅对 NatTable 中的视口层的选定行数禁用“行选择”?

[英]How to disable "Row Selection" for only selected number of rows of viewport layer in a NatTable?

My NatTable contain CompositeFreezeLayer composed from viewport, body and selection layer.我的NatTable包含由视口、主体和选择层组成的CompositeFreezeLayer

I want to disable a row selection for the frozen rows.我想禁用冻结行的行选择。

That means, in my table I have 15 rows.这意味着,在我的表中有 15 行。 In these, 5 rows get frozen, that rows should be disabled for selection.在这些中,有 5 行被冻结,应禁用该行以供选择。 And the other 10 rows should be enabled with row/cell selection.其他 10 行应启用行/单元格选择。

Currently by default all the rows are selecting, may be that should be configured by default through selection layer it seems.当前默认情况下所有行都在选择,可能是默认情况下应该通过选择层进行配置。

How to disable row selection for only few row?如何仅禁用几行的行选择?

Implement a custom command handler that checks the position and consumes the command for positions in the frozen area.实现一个自定义命令处理程序,用于检查位置并使用冻结区域中位置的命令。 For other rows forward the command.对于其他行转发命令。 Register that command handler on the CompositeFreezeLayer.在 CompositeFreezeLayer 上注册该命令处理程序。

As I want to disable the Row Selection and Cell Selection on Frozen Layer, So Check the instance of both the commands and forwarding the commands.由于我想禁用冻结层上的行选择和单元格选择,因此请检查命令的实例并转发命令。

public class CustomFreezeLayerCommandHandler implements ILayerCommandHandler<ILayerCommand>
{

  private int endRowOfFrozenLayer;

  public CustomFreezeLayerCommandHandler(final int lastRowOfFrozenLayer)
  {
    this.endRowOfFrozenLayer = lastRowOfFrozenLayer;
  }


  @Override
  public boolean doCommand(final ILayer targetLayer, final ILayerCommand command)
  {
    if (command instanceof ViewportSelectRowCommand)
    {
      return (((ViewportSelectRowCommand) command).getRowPosition() <= this.endRowOfFrozenLayer);
    }
    else if (command instanceof SelectCellCommand)
    {

      return (((SelectCellCommand) command).getRowPosition() <= this.endRowOfFrozenLayer);
    }
    return false;

  }

  @Override
  public Class<ILayerCommand> getCommandClass()
  {
    return ILayerCommand.class;
  }

}

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

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