import {
  AnalyticalScope, BaseGrid,
  Behavior,
  NotNull,
  ObjectRef,
  Visible
} from "@webbpm/base-package";

@AnalyticalScope("BaseGrid")
export class GridDataTransfer extends Behavior {
  private grid: BaseGrid;

  @ObjectRef()
  @NotNull()
  public gridRef: BaseGrid;

  initialize() {
    this.grid = this.getScript(BaseGrid);
  }

  @Visible()
  public copyValuesToTargetGrid() {
    this.grid.removeRows(this.grid.getAllRows());
    this.grid.addRows(this.gridRef.getAllRows());
  }
}