最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to hide ag-grid if rowData is null? - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question edited Jan 24, 2020 at 13:46 David 74511 silver badges25 bronze badges asked Jul 29, 2015 at 23:53 lostalienlostalien 1151 silver badge12 bronze badges 3
  • There are many solutions for this problem and if you post code (or create example with jsfiddle or plunker - will be the best) it will really help to give a better advise. – Alex Netkachov Commented Jul 30, 2015 at 0:46
  • it's hard to make a suggestion without seeing the code you have, but using ng-if="rowData" should work.... – Claies Commented Jul 30, 2015 at 0:46
  • I don't think that ag-grid stands for "Angular Grid". Do you use something like ng-grid instead? – DerMike Commented Oct 28, 2016 at 13:57
Add a ment  | 

1 Answer 1

Reset to default 3

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.

发布评论

评论列表(0)

  1. 暂无评论