Ag-grid Angular firstDataRendered不会触发 [英] Ag-grid Angular firstDataRendered does not fire

查看:73
本文介绍了Ag-grid Angular firstDataRendered不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为数据表使用ag-grid.在测试事件firstDataRendered时,它根本不会触发,而gridReady会触发.我只是分配了一个基本功能fire(){console.log("HEY")}.有什么能阻止此事件的发生?

I am using ag-grid for my data table. When testing the event firstDataRendered, it does not fire at all while gridReady does fire. I just have a basic function fire() { console.log("HEY") } assigned to it. Is there anything that blocks this event from fire?

<ag-grid-angular 
  style="width: auto; height: 250px"
  [rowData]="tblData"
  [columnDefs]="tableHeaders"
  [gridOptions]="gridOptions"
  [defaultColDef]="defaultColDef"
  (firstDataRendered)="fire($event)"
  (gridReady)="onGridReady($event)">
</ag-grid-angular>

推荐答案

我不确定这是否适用于您的问题,但是如果网格中没有任何行,则firstDataRendered将不会启动(对我来说似乎很la脚,但他们说这是设计使然).

I'm not sure if this is applicable to your issue, but firstDataRendered will not fire if there are no rows for the grid (seems lame to me but they say this is by design).

您可以通过检查行数据长度在gridReady事件中检测到此问题:

You can detect this in the gridReady event by checking the row data length:

 if (this.rowData.length === 0) {
     // firstDataRendered will not fire here - 
     // but this is where you can process the 'no data' code. 
  }

这篇关于Ag-grid Angular firstDataRendered不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆