如何在 syncfusion Grid 组件中隐藏 Grid Spinner

How to hide grid spinner in syncfusion Grid component

我在我的项目中使用 syncfusion angular GridComponent。我希望网格在创建后有一个微调器,微调器应该旋转直到数据被加载。 为了启动微调器,我为创建网格时编写了一个函数:

文档-table.component.html

<ejs-grid #grid (created)="creadted()" ...>
...
</ejs-grid>

文档-table.component.ts:

@ViewChild('grid') grid: GridComponent
ngOnChanges(changes: SimpleChanges){
   this.tableData = changes.data.currentValue;
   if(changes.data.currentValue != null){
      this.grid.hideSpinner=()=>false; //it doesn't work and the spinner still spinning
   }
created(){
   this.grid.hideSpinner =()=>true; //spinner start spinning
}

如何在加载数据后停止微调器?

ejs-gird docs 说:

By default, grid shows the spinner for all its actions.

所以我不确定您是否需要为您的操作手动设置微调器。

如果您必须手动设置微调器,如果您想根据对网格所做的某些更改触发函数,则可能需要使用 setTimeout() 包装函数调用。

@ViewChild('grid') grid: GridComponent
ngOnChanges(changes: SimpleChanges){
   this.tableData = changes.data.currentValue;
   if(changes.data.currentValue != null) {
      setTimeout(() => this.grid.hideSpinner(), 0)
   }
}
created() {
   setTimeout(() => this.grid.showSpinner(), 0)
}

另请参阅:Why is setTimeout(fn, 0) sometimes useful?