用数据重新填充农业网格

编程入门 行业动态 更新时间:2024-10-10 04:28:48
本文介绍了用数据重新填充农业网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用组件文件中的 onGridReady 方法从html初始化ag-grid。

I am initialising the ag-grid from the html using an onGridReady method in the component file.

<div style="flex-grow:1;"> <ag-grid-angular style="float:left;width: 100%; height: 201px;margin-top:10px;" class="ag-theme-balham" [gridOptions]="gridOptions" [columnDefs]="columnDefs" (gridReady)="onGridReady($event)" [rowData]="rowData" #grid > </ag-grid-angular> </div>

在我正在处理的 .ts 文件中 onGridReady 如下:

In my .ts file i am handling the onGridReady like below :

onGridReady(params?: any) { console.log("onGridReady"); var datasource = { getRows: (params: IGetRowsParams) => { this.info = "Getting datasource rows, start: " + params.startRow + ", end: " + params.endRow; console.log(this.info); this.getRowData().then(data => { if (this.stopApiCalls) { var lastRow = this.allTableData.length; params.successCallback(data, lastRow) } else { params.successCallback(data) } }) } }; console.log(">>",datasource); params.api.setDatasource(datasource); }

this.getRowData 用于使用http从后端服务获取数据。

this.getRowData is used to get the data from the backend service using http.

我现在需要重新启动并在不同组件文件中处理的某个事件上使用 onGridReady 。我可以访问我的ag-grid组件中的方法。但是如何从其他组件调用 onGridReady 事件?

I now need to reinitalise and use onGridReady on a certain event handled in a different component file. I am able to access the methods in my ag-grid component. But how can i call the onGridReady event from the other component?

推荐答案

gridReady 事件恰好在网格初始化之后发生,所以如果您想要获得动态组件,将需要更复杂的解决方案。

gridReady event occurs exactly after grid initialization, so if you wanna to get dynamic component it would require a more complex solution.

可能的破解:通过带有动态参数的路由器重新渲染视图

possible hack: rerender the view, via router with dynamic parameters

更多推荐

用数据重新填充农业网格

本文发布于:2023-11-22 22:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619188.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   农业   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!