angularjs – 如何隐藏ng网格中的列

前端之家收集整理的这篇文章主要介绍了angularjs – 如何隐藏ng网格中的列前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的代码

的index.html

<!DOCTYPE html>
<html ng-app="myApp">

<head>
  <Meta charset="utf-8" />
  <title>AngularJS Plunker</title>
  <link rel="stylesheet" type="text/css" href="http://angular-ui.github.com/ng- grid/css/ng-grid.css" />
  <link rel="stylesheet" type="text/css" href="style.css" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
  <script type="text/javascript" src="http://angular-ui.github.com/ng-grid/lib/ng-grid.debug.js"></script>
  <script src="app.js"></script>
</head>

<body ng-controller="MyCtrl">
    <div class="gridStyle" ng-grid="gridOptions"></div>
    <div class="selectedItems">Selected ID:{{mySelections[0].id}}</div><br><br>

</body>

</html>

app.js

var app = angular.module('myApp',['ngGrid']);
app.controller('MyCtrl',function($scope) {
  $scope.mySelections = [];
  $scope.myData = [{empno: 111,name: "Moroni",id: 1},{empno: 222,name: "Tiancum",id: 2},{empno: 333,name: "Jacob",id: 3},{empno: 444,name: "Nephi",id: 4},{empno: 555,name: "Akon",id: 5},{empno: 666,name: "Enos",id: 6}];
  $scope.gridOptions = { 
    data: 'myData',selectedItems: $scope.mySelections,multiSelect: false
  };
});

Q1:我想隐藏ng网格中的id列。
Q2:隐藏id列后,我可以在选择一行时获取id值吗?
如何修改代码

听到是这样的人:Plunk demo

只需将下面的行添加到配置中即可
columnDefs: [
            {field: 'empno',displayName: 'empno'},{field:'name',displayName:'name'}
        ]

猜你在找的Angularjs相关文章