0
votes

I have a table which hides some rows from a table when a checkbox is selected. Initally it shows that count which I've precalculated. I'm using ng-show to hide/show a row. So the length function still returns the total count.

<input type="checkbox" ng-model="isRChecked" id="chck3" ng-change="ExcludeRChecked();"><label for="chck3">Exclude R</label>


<div>{{Detail.length}} Rows in Table</div>
<tbody>
  <tr ng-repeat="x in Detail" ng-show="excludeR(x.ID)">
    <td colspan="1">{{x.feature}}</td>
    <td colspan="1" ng-click="test(x.ID)">{{x.ID}}</td>
    <td colspan="1">{{x.Log}}</td>
  </tr>
</tbody>

I have to display the number of rows in the table. So when the checkbox is selected, the hidden row count from ng-show should be removed.

The angular function ExcludeR()

 $scope.excludeR=function(item){
            if($scope.isRChecked===false)
                return true;
                for(x in $scope.R){
                    if($scope.R[x]===item)
                    {                           
                        return false;
                    }
                }
                return true;

        };
2
can you add your checkbox code also?Jahongir Rahmonov

2 Answers

1
votes
<div>{{visibleDetailsCount}} Rows in Table</div>
<tbody>
  <tr ng-repeat="x in Detail" ng-show="excludeR(x.ID)">


$scope.excludeR(param){
   //...
   condition?$scope.visibleDetailsCount++:$scope.visibleDetailsCount--;
   //...
}
0
votes

Prefilter Detail in controller

$scope.filteredDetail = $scope.Detail.filter(x => excludeR(x.ID))

<div>{{filteredDetail.length}} Rows in Table</div>
<tbody>
  <tr ng-repeat="x in filteredDetails track by x.ID ">
    <td colspan="1">{{x.feature}}</td>
    <td colspan="1" ng-click="test(x.ID)">{{x.ID}}</td>
    <td colspan="1">{{x.Log}}</td>
  </tr>
</tbody>