Vimal
Vimal

Reputation: 2857

Is it possible to remove a row depends on a particular value in AngularJs ui grid?

I want to display a list of data using ui grid. In that grid I want to filter some rows depends on the the value.

var app = angular.module('uigrid', ['ui.grid']);

app.controller('MainCtrl', ['$scope', function ($scope) {
$scope.myData = [{name: "Moroni", age: 50},
                 {name: "Tiancum", age: 43},
                 {name: "Jacob", age: 27, visible: "false"},
                 {name: "Nephi", age: 29, visible: "false"},
                 {name: "Enos", age: 34}];

$scope.gridOptions = {
  enableRowSelection: true,
  enableSelectAll: true,
  multiSelect: true,
  enableColumnMenus: false,
  enableFiltering: true,
  rowHeight: 40,
  data : 'myData',
  columnDefs: [
    {
      name: 'name',
      displayName: 'Name'
    },
    {
      name: 'age',
      displayName: 'Age'
    },]
  };
}]);

In this list I don't want to display two rows with that property visible: "false"? Which is the best way to remove that rows? I have created the grid Example

Thanks in advance.

Upvotes: 1

Views: 38

Answers (1)

Saurabh Agrawal
Saurabh Agrawal

Reputation: 7739

You can use this in your $scope.gridOptions to show/hide rows

appScopeProvider: {
  showRow: function(row) {
    return row.visible !== 'false';
  }
},

Here is the working plunker.

Upvotes: 3

Related Questions