Angular: V3. Multiple Tables with level2 ng-collapse
DOM filled with all Level 2 tables also. (Pimped with radius corners etc.)
HTML
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.4.0.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app="myApp">
<div class="container">
<div ng-controller="myController" class="row-fluid span12">
<div class="row">
<div class="col-6 col-sm-4">
<input type="text">
</div>
<div class="col-6 col-sm-4">
<input type="text">
</div>
</div>
<div class="row">
<div class="">
<input type="text">
</div>
<div class="">
<input type="text">
</div>
</div>
<div>
<table class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th>Store ID</th>
<th>Name</th>
<th>Address</th>
<th>City</th>
<th>Cost</th>
<th>Sales</th>
<th>Revenue</th>
<th>Employees</th>
<th>Employees H-sum</th>
</tr>
</thead>
<tbody data-ng-repeat="storedata in storeDataModel.storedata">
<tr id="storedata.store.storeId" class="clickableRow" title="Click to toggle collapse/expand day summaries for this store." data-ng-click="selectTableRow($index, storedata.store.storeId)">
<td>{{storedata.store.storeId}}</td>
<td>{{storedata.store.storeName}}</td>
...
CSS
body {
padding: 10px;
padding-right:30px;
}
table {
border-collapse: separate;
border-spacing: 0 5px;
padding: 0px;
}
thead th {
background-color: #006DCC;
color: white;
}
tbody td {
<!-- background-color: #EEEEEE;
-->
}
tr td:first-child,
tr th:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
tr td:last-child,
tr th:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
.clickableRow {
cursor: pointer;
}
p, textarea {
font-variant: small-caps !important;
text-rendering: auto;
}
td, th {
font-size: 8pt;
}
table {
padding: 0px;
}
JavaScript
var myApp = angular.module('myApp', ['ui.bootstrap']);
myApp.controller('myController', function ($scope) {
$scope.tableRowExpanded = false;
$scope.tableRowIndexCurrExpanded = "";
$scope.tableRowIndexPrevExpanded = "";
$scope.storeIdExpanded = "";
$scope.dayDataCollapseFn = function () {
$scope.dayDataCollapse = [];
for (var i = 0; i < $scope.storeDataModel.storedata.length; i += 1) {
$scope.dayDataCollapse.push(false);
}
};
$scope.selectTableRow = function (index, storeId) {
if ($scope.dayDataCollapse === undefined) {
$scope.dayDataCollapseFn();
}
if ($scope.tableRowExpanded === false && $scope.tableRowIndexCurrExpanded === "" && $scope.storeIdExpanded === "") {
$scope.tableRowIndexPrevExpanded = "";
$scope.tableRowExpanded = true;
$scope.tableRowIndexCurrExpanded = index;
$scope.storeIdExpanded = storeId;
$scope.dayDataCollapse[index] = true;
} else if ($scope.tableRowExpanded === true) {
if ($scope.tableRowIndexCurrExpanded === index && $scope.storeIdExpanded === storeId) {
$scope.tableRowExpanded = false;
$scope.tableRowIndexCurrExpanded = "";
$scope.storeIdExpanded = "";
$scope.dayDataCollapse[index] = false;
} else {
$scope.tableRowIndexPrevExpanded = $scope.tableRowIndexCurrExpanded;
$scope.tableRowIndexCurrExpanded = index;
$scope.storeIdExpanded = storeId;
$scope.dayDataCollapse[$scope.tableRowIndexPrevExpanded] = false;
$scope.dayDataCollapse[$scope.tableRowIndexCurrExpanded] = true;
}
}
};
$scope.storeDataModel = {
"metadata": {
"storesInTotal": "25",
...