How to hide ag-grid if rowData is null?

好久不见. 提交于 2019-12-23 04:09:29

问题


I have a use case where the ag-grid (Angular Grid) I am using must not appear at all if the rowData is null that is returned from the Model code.

As of now I am unable to find a way to do it at the grid level.

What would be the right way to implement this? If hiding the div element is the way to do it, how does one doit in aright way from JavaScript?


回答1:


If you want to hide the grid if no rows, then use an ng-if or an ng-show, pointing to the gridOptions.data.

<div ng-grid="gridOptions" ng-show="gridOptions.rowData.length>0"/>

or

<div ng-grid="gridOptions" ng-if="gridOptions.rowData.length>0"/>

If you use show, then the grid will stay there, but Angular will apply css to hide the element.

If you use if, then the grid directive will not be initialised by AngularJS until you have data present in rowData.



来源:https://stackoverflow.com/questions/31713093/how-to-hide-ag-grid-if-rowdata-is-null

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