在Ag-Grid中加载数据时如何避免出现“无行”消息

pra*_*lli 2 rxjs ag-grid ngrx angular ngrx-store

我有一个ag-grid,它通过restful调用从后端提取数据,并通过NGRX模式进行路由。

   <ag-grid-angular #agGrid class="ag-theme-fresh" style="width: 100%; height: 100%;" [gridOptions]="gridOptions"
                 [rowData]="rowData"
                 [pagination]="true" [paginationAutoPageSize]='true' [enableSorting]="true"
                 [rowSelection]="rowSelection" [enableColResize]="true"
                 [enableFilter]="true" [rowClassRules]="rowClassRules" (rowClicked)="onRowClicked($event)"
                 (cellClicked)="onCellClicked($event)"
                 (gridReady)="onReady($event)">
</ag-grid-angular>
Run Code Online (Sandbox Code Playgroud)

我有2个场景,其中网格加载了数据。

场景1:我第一次在页面加载时加载它(通过ngrx store)

  this.QueueItems$ = this.store.select(fromStore.getQueueItems);
Run Code Online (Sandbox Code Playgroud)

场景2:第二次,我有一个按钮,用于刷新另一个商店中网格中的数据。

     <button mat-icon-button matTooltip="Refresh Grid" 
     (click)="handleOnGridRefesh($event)" matTooltipPosition="left"
      style="right: 2%;top: 0;margin-top: 7px;position: absolute;z-index:4">
     <i class="fa fa-refresh" style="color:#455A64" aria-hidden="true"></i>
      </button>


   //note:getQueueItemsStore is a different store ( ngrx) from getQueueItems
   handleOnGridRefesh($event: any) {
this.QueueItems$ = this.store.select(fromStore.getQueueItemsStore);
 }
Run Code Online (Sandbox Code Playgroud)

我的问题是,单击按钮刷新网格后,ag网格提取数据并显示“没有要显示的行”覆盖,这是500ms到1秒的短暂时间延迟。

如何没有如图所示的中间覆盖的情况下平稳过渡

Irv*_*ing 5

suppressNoRowsOverlay: true在他们的评论中使用了建议的bc1105,但这始终隐藏了覆盖图。如果加载完成后没有任何数据,我仍想显示叠加层。为了克服这个问题,我做了以下工作:

this.gridOptions.suppressNoRowsOverlay = true;
this.service.getData()
  .subscribe(data => {
    if (!data || !data.length) {
      this.gridOptions.suppressNoRowsOverlay = false;
      this.gridOptions.api.showNoRowsOverlay();
    }
Run Code Online (Sandbox Code Playgroud)

  • 这不会影响加载叠加。有单独的属性 - `gridOptions.suppressLoadingOverlay` 和 `gridOptions.api.showLoadingOverlay()` (2认同)