简体   繁体   English

如果 rowData 为空,如何隐藏 ag-grid?

[英]How to hide ag-grid if rowData is null?

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.我有一个用例,如果模型代码返回的 rowData 为 null,则我使用的ag-grid (Angular Grid)根本不会出现。

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?如果隐藏 div 元素是一种方法,那么 JavaScript 如何以正确的方式进行呢?

If you want to hide the grid if no rows, then use an ng-if or an ng-show, pointing to the gridOptions.data.如果要在没有行的情况下隐藏网格,请使用 ng-if 或 ng-show,指向 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.如果您使用 show,则网格将保留在那里,但 Angular 将应用 css 来隐藏元素。

If you use if, then the grid directive will not be initialised by AngularJS until you have data present in rowData.如果您使用 if,则在 rowData 中存在数据之前,AngularJS 不会初始化 grid 指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM