NG-表分组:仅打开排在一个时间 [英] ng-Table Grouping: Open only row at a time

查看:164
本文介绍了NG-表分组:仅打开排在一个时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最好在NG-表一次只显示一个打开一行。在present,如果行被打开,然后将直到用户手动将其折叠继续开放。由于每个新行被打开,对显示越来越多的数据。

I'd to display only one open row at a time in ng-Table. At present, if a row is opened then it will stay open until the user collapses it manually. As each new row is opened, there is more and more data on display.

我使用这个code以启动表中的所有行关闭,但我在如何保持只有一排封闭难住了。

I'm using this code to initiate the table with all rows closed, but I'm stumped at how to keep only one row closed.

app.controller('groupCtrl', function($scope) {
   $scope.group.$hideRows = true;
});

这plunkr显示迄今取得的进展( http://plnkr.co/edit / 2ABVrN?p = preVIEW )。

This plunkr shows the progress to date (http://plnkr.co/edit/2ABVrN?p=preview).

泰德

推荐答案

要通过所有组个人组控制器和折叠所有展开的群体,除了这个想法选择

The idea to pass all groups to individual group controller and collapse all expanded groups except selected

查看HTML:

<tbody ng-repeat="group in $groups | orderBy:'value'"  sortable="'sortletter'" 
  ng-controller="groupCtrl">
  <tr class="ng-table-group">
    <td colspan="{{$columns.length}}">
      <a href="" ng-click="switchGroup(group, $parent.$groups)">

groupCtrl:

groupCtrl:

app.controller('groupCtrl', function($scope) {
  //console.log($scope); 
  $scope.group.$hideRows = true;
  //     console.log("scope.group.$hideRows"+$scope.group.$hideRows);

  $scope.switchGroup = function(group, groups){
    if(group.$hideRows){
      angular.forEach(groups, function(g){
        if(g !== group){
          g.$hideRows = true;
        }
      });
    }

    group.$hideRows = !group.$hideRows;
  };
});    

Plunker

这篇关于NG-表分组:仅打开排在一个时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆