I'm new to AngularJS and SmartTable...I'm currently trying to get SmartTable to have a show/hide toggle for the columns. From what I undertstand SmartTable doesn't do this, so I am using the ng-Grid show/hide feature...trying to follow this solution: how to hide/show ng-grid column externally?
When I implemented this solution my columns aren't showing up.
How do you set smartTable columns to "show" upon initial set up? I think this is what I'm missing...
Here is my 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());
}
}]);
and here's my 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" st-sort="balance">balance</th>
<th>email</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rowCollection">
<td>{{row.firstName}}</td>
<td>{{row.lastName}}</td>
<td>{{row.balance}}</td>
<td>{{row.email}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="text-center" colspan="5">
<div st-displayed-pages="7" st-items-by-page="itemsByPage" st-pagination=""></div>
</td>
</tr>
</tfoot>
</table>
You can see my entire setup on my plunker example:
http://plnkr.co/edit/6F8NsDdgaWranTXeIQuV?p=preview
Thanks!!