简体   繁体   中英

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.

I want to disable a row selection for the frozen rows.

That means, in my table I have 15 rows. In these, 5 rows get frozen, that rows should be disabled for selection. And the other 10 rows should be enabled with row/cell selection.

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.

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;
  }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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