如何根据输入隐藏和显示带有列的UI网格

问题描述 投票:0回答:1

我正在使用Angular UI Grid。我想根据复选框输入显示UI Grid。我能够隐藏和显示基于复选框的网格,但永远不能在UI网格中显示列。

HTML代码

<table>
   <tr>
    <td valign="top">
         <label>Recursive</label>
    </td>
   </tr>
   <tr>
    <td valign="top">
          <input type="checkbox" ng-model="eventadd.md_eventrecursive"
                 ng-true-value="true" ng-false-value="false">
    </td>
   </tr>
</table>
<br/>
<div ng-show="eventadd.md_eventrecursive">
   <div ui-grid="gridRecursiveEvent" class="gridSmallStyle"></div>
</div>

JS代码

$scope.gridRecursiveEvent = {
    columnDefs: [
        {
            field: 'Name', displayName: 'Name'
        },
        {
            field: 'Id', displayName: 'Id',
        },
    ],
}

选中Recursive事件时,它会显示Grid但没有Columns

enter image description here

需要你的帮助。

angularjs angular-ui-grid
1个回答
1
投票

请参考this page

问题是网格最初没有渲染(因为它是隐藏的)。选中该复选框不会呈现ui-grid。

请参阅文档,了解适合您的愿望的可能的解决方法。

© www.soinside.com 2019 - 2024. All rights reserved.