我是AngularJS和SmartTable的新手......我现在正试图让SmartTable为列进行显示/隐藏切换.从我的承诺SmartTable不这样做,所以我使用ng-Grid显示/隐藏功能...试图遵循这个解决方案: 如何在外部隐藏/显示ng-grid列?
当我实现此解决方案时,我的列没有显示出来.
如何在初始设置时将smartTable列设置为"show"?我想这就是我所缺少的......
这是我的js:
var app = angular.module('myApp', ['smart-table', 'ngGrid']);
app.controller('paginationCtrl', ['$scope', function (scope) {
var nameList = ['Brian', 'Bob', 'Marie', 'Jennifer', 'Frank'],
familyName = ['Smith', 'Miller', 'Patel', 'Jefferson', 'Mendez'];
...
$scope.toggleCol= function(i) {
$scope.gridOptions.$gridScope.columns[i].toggleVisible()
}
scope.itemsByPage=15;
scope.rowCollection = [];
for (var j = 0; j < 200; j++) {
scope.rowCollection.push(createRandomItem());
}
}]);
Run Code Online (Sandbox Code Playgroud)
这是我的HTML:
<body ng-controller="paginationCtrl">
<p>Smart Table Example</p>
<input type="button" value="First Name" ng-click="toggleCol(0)" />
<table class="table table-striped" st-table="rowCollection">
<thead>
<tr>
<th st-sort="firstName">first name</th>
<th st-sort="lastName">last name</th>
<th st-skip-natural="true" …
Run Code Online (Sandbox Code Playgroud) 我是angularjs和ng-grid的新手......我目前正在通过一个简单的ng-grid示例,但我似乎无法让它工作.
这是我的HTML:
<!DOCTYPE html>
<html ng-app="myApp">
<head lang="en">
<meta charset="utf-8">
<title>Getting Started With ngGrid Example</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/ng-grid/2.0.11/ng-grid.css" data-semver="2.0.11" data-require="ng-grid@*" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" data-semver="2.1.1" data-require="jquery@*"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular.js" data-semver="1.3.7" data-require="angular.js@*"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ng-grid/2.0.11/ng-grid.min.js" data-semver="2.0.11" data-require="ng-grid@*"></script>
<script src="js/controllers.js"></script>
</head>
<body ng-controller="MyCtrl">
<h1>{{title}}</h1>
<div class="gridStyle" ng-grid="gridOptions">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的js:
'use strict';
var app = angular.module('myApp', ['ui.grid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: …
Run Code Online (Sandbox Code Playgroud)