首页 > 解决方案 > 如何在syncfusion Grid组件中隐藏网格微调器

问题描述

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

文档-table.component.html

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

文档表.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
}

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

标签: angularsyncfusion

解决方案


ejs -gird 文档说:

默认情况下,grid 显示所有动作的微调器。

因此,如果您需要为您的操作手动设置微调器,我不放心。

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

@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)
}

另请参阅:为什么 setTimeout(fn, 0) 有时有用?


推荐阅读