Using a button click event, destroy the ag-grid

烈酒焚心 提交于 2021-02-20 15:30:22

问题


Using plain old javascript version of ag-grid.

I would like to destroy the ag-grid that is in a div from a button click event.

How do i destroy the grid?


回答1:


There is a method named destory().

As per documentation:

destroy()
Gets the grid to destroy and release resources. If you are using Angular (version 1 or 2) you do not need to call this, as the grid links in with the AngularJS 1.x lifecycle. However if you are using Web Components or native Javascript, you do need to call this, to avoid a memory leak in your application.

Have a look at the Plunk - Destroy grid I created.

gridOptions.api.destroy();

As you can see, by calling this function, the grid gets destroyed. As described in the documentation, it not only clears the DOM, but also takes care of memory leaks.



来源:https://stackoverflow.com/questions/49077836/using-a-button-click-event-destroy-the-ag-grid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!