NG-表分组 - 初始化最小行 [英] ng-table grouping - initialize with rows minimised
问题描述
我使用的 http://plnkr.co/edit/CBcbkc
现在表被初始化具有扩展行,但我想他们被最小化,因为我有超过100个的记录。我怎样才能做到这一点?
Right now the table is initialised with rows expanded, but I would like them to be minimised as I have over 100 records. How can I do this?
推荐答案
您可以使用的组$ hideRows 为true://文档.angularjs.org / API / NG /指令/ ngInit> ngInit
:
You can set group.$hideRows
to true using ngInit
:
< TBODY NG重复=$中的组群NG-的init =组$ hideRows =真。>
更新结果
我想找到一个更好的解决方案,因为角度的文档使用劝阻 ngInit
访问范围变量。
Update
I wanted to find a better solution, because the angular docs discourage using ngInit
to access scope variables.
您可以创建在 NG-重复创建的每个组控制器
:
<tbody ng-repeat="group in $groups" ng-controller="groupCtrl">
然后,您可以直接访问组对象。这样做的一个优点是,可以有条件地扩大的基团的能力:
Then, you can access the group object directly. One advantage of this would be the ability to conditionally expand a group:
.controller('groupCtrl', function($scope) {
if ($scope.group.value != 'Administrator')
$scope.group.$hideRows = true;
});
仅供参考结果
我不知道为什么我不能找到 $ hideRows
源的任何引用。原来,该组对象不具有<code> $ hideRows 属性后才被点击。为了证明这一点,我换成 $ hideRows
用由名字和它的工作是一样的。
FYI
I wondered why I couldn't find any references to $hideRows
in the source. It turns out that the group object doesn't have a $hideRows
property until after it is clicked. To prove this, I replaced $hideRows
with a made up name and it worked just the same.
<tbody ng-repeat="group in $groups">
<tr class="ng-table-group">
<td colspan="{{$columns.length}}">
<a href="" ng-click="group.invokeInvisbility = !group.invokeInvisbility">
<span class="glyphicon" ng-class="{ 'glyphicon-chevron-right': group.invokeInvisbility, 'glyphicon-chevron-down': !group.invokeInvisbility }"></span>
<strong>{{ group.value }}</strong>
</a>
</td>
</tr>
<tr ng-hide="group.invokeInvisbility" ng-repeat="user in group.data">
怪不得你无法找到一个方法来初始化。
No wonder you couldn't find a way to initialize it.
这篇关于NG-表分组 - 初始化最小行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!