<div class="department-windreamsearch-windreamindex">
  <label class="label">{{windreamIndexList._listName}}</label>
  <section class="toolbar">
    <div class="toolbar-button-row">
      <div class="toolbar-flex-container">
        <button mat-icon-button title="Hinzufügen" (click)=addItem()
          [disabled]="!(departmentDetails.inEditMode
                      && !windreamSearchToDepartmentDetails.entityIsLoading
                      && !windreamSearchToDepartmentDetails.isNew
                      && windreamIndexList.focusedEntityShadowed.enabledNewButton())">
          <mat-icon>add</mat-icon>
        </button>
        <!-- <button mat-icon-button title="Bearbeiten" (click)=editItem()
                    [disabled]="!departmentDetails.inEditMode || windreamIndexList.focusedItemId===0 || !windreamIndexList.focusedEntityShadowed.enabledEditButton()">
                    <mat-icon>edit</mat-icon>
                </button> -->
        <button mat-icon-button title="Kopieren zum Zwischenspeicher" (click)="copyWindreamOutCols()"
          [disabled]="!(!windreamSearchToDepartmentDetails.entityIsLoading
                      && !windreamSearchToDepartmentDetails.isNew
                      && windreamIndexList.items.length > 0)">
          <mat-icon>content_copy</mat-icon>
        </button>
        <button mat-icon-button [title]="departmentDataService.clpbrdWindreamOutColHint1+'\n'+departmentDataService.clpbrdWindreamOutColHints" (click)="pasteWindreamOutCols()"
          [disabled]="!(departmentDataService.clpbrdWindreamOutColHint1
                      && departmentDetails.inEditMode
                      && !windreamSearchToDepartmentDetails.entityIsLoading
                      && !windreamSearchToDepartmentDetails.isNew)">
          <mat-icon>content_paste</mat-icon>
        </button>
        <button mat-icon-button title="Löschen"
          (click)=windreamIndexList.focusedEntityShadowed.delete();
          [disabled]="!(departmentDetails.inEditMode
                      && !windreamSearchToDepartmentDetails.entityIsLoading
                      && !windreamSearchToDepartmentDetails.isNew
                      && !windreamIndexList.focusedEntityShadowed.isNew
                      && windreamIndexList.focusedEntityShadowed.enabledDeleteButton())">
          <mat-icon>delete</mat-icon>
        </button>
        <button mat-icon-button title="Vorrücken"
          (click)="departmentDataService.moveUpDown(-1, windreamIndexList)"
          [disabled]="!(departmentDetails.inEditMode
                      && !windreamSearchToDepartmentDetails.entityIsLoading
                      && !windreamSearchToDepartmentDetails.isNew
                      && !windreamIndexList.focusedEntityShadowed.isNew
                      && windreamIndexList.focusedItemIndex>0)">
          <mat-icon>keyboard_arrow_up</mat-icon>
        </button>
        <button mat-icon-button title="Hinterrücken" class="toolbar-button-last"
          (click)="departmentDataService.moveUpDown(1, windreamIndexList)"
          [disabled]="!(departmentDetails.inEditMode
                      && !windreamSearchToDepartmentDetails.entityIsLoading
                      && !windreamSearchToDepartmentDetails.isNew
                      && !windreamIndexList.focusedEntityShadowed.isNew
                      && windreamIndexList.focusedItemIndex<windreamIndexList.items.length-1)">
          <mat-icon>keyboard_arrow_down</mat-icon>
        </button>
      </div>
    </div>
  </section>
  <dx-data-grid
    name="windreamSearchGrid"
    [class]="'grid'+(columnConfigList.withExport ? ' withexport' : '')"
    [dataSource]="windreamIndexList.items"
    keyExpr="entityId"
    [(focusedRowIndex)]=windreamIndexList.focusedItemGridIndex
    [focusedRowEnabled]="true"
    [autoNavigateToFocusedRow]="true"
    [(focusedRowKey)]="windreamIndexList.focusedItemId"
    [(selectedRowKeys)]="windreamIndexList.selectedItemIds"
    [showBorders]="true" [allowColumnResizing]="true"
    columnResizingMode="widget"
    noDataText="Keine Daten sind vorhanden"
    [renderAsync]="true"
    (onKeyDown)="$event.handled = $event.event.key==='Escape'"
    (onExporting)="globals.doExcelExportSimple($event, windreamIndexList.getExportFilename4List())">

    <dxo-export [enabled]="columnConfigList.withExport" [texts]="{exportAll: 'Excel Export'}"></dxo-export>
    <dxo-header-filter [visible]="true"></dxo-header-filter> -->
    <dxo-filter-row [visible]="false" [applyFilter]="true"></dxo-filter-row>
    <dxo-paging [enabled]="false"></dxo-paging>
    <dxo-scrolling mode="virtual"></dxo-scrolling>
    <dxo-load-panel [enabled]="true"></dxo-load-panel>
    <dxo-sorting mode="multiple"></dxo-sorting>
    <dxo-selection mode="none"></dxo-selection>

    <ng-container *ngFor="let column of columnConfigList.columns">
      <ng-container *ngIf="column.visible">
        <dxi-column [allowHeaderFiltering]=column.allowHeaderFiltering [dataField]=column.dataField
          [dataType]=column.dataType [caption]=column.caption [width]=column.width
          [sortIndex]=column.sortIndex [sortOrder]=column.sortOrder [visibleIndex]=column.visibleIndex
          [visible]=column.visible [fixed]=column.fixed [headerCellTemplate]=column.headerCellTemplate
          [cellTemplate]=column.cellTemplate [allowSorting]=column.allowSorting
          [calculateCellValue]=column.calculateCellValue [calculateDisplayValue]=column.calculateDisplayValue
          [calculateGroupValue]=column.calculateGroupValue [calculateSortValue]=column.calculateSortValue
          [alignment]=column.alignment>
          <dxo-format *ngIf="column.dataType == 'date'" [type]=localeService.dateFormat></dxo-format>
          <dxo-format *ngIf="column.dataType == 'datetime'" [type]=localeService.dateTimeFormat></dxo-format>
        </dxi-column>
      </ng-container>
    </ng-container>

    <div *dxTemplate="let cell of 'numberTemplate_0'">
      {{cell.value | number:'1.0-0':culture}}
    </div>
    <div *dxTemplate="let cell of 'numberTemplate_1'">
      {{cell.value | number:'1.1-1':culture}}
    </div>
    <div *dxTemplate="let cell of 'numberTemplate_2'">
      {{cell.value | number:'1.2-2':culture}}
    </div>
    <div *dxTemplate="let cell of 'numberTemplate_3'">
      {{cell.value | number:'1.3-3':culture}}
    </div>
  </dx-data-grid>
</div>
