Angular: V4. Multiple ng-repeat tables (Not filling DOM w. LVL2)
DOM NOT filled with all Level 2 tables. (Pimped with radius corners etc.)
by Pixic
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.4.0.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<div ng-controller="myController">
<div class="span12 row-fluid">
<!-- START $scope.[model] updates -->
<div class="span12 well well-small">
<div class="span4">
<p class="nav-header">collapse/expand tableRow</p>
<p class="small-caps">
tableRowExpanded: <b>{{tableRowExpanded}}</b><br/>
tableRowIndexExpandedCurr: <b>{{tableRowIndexExpandedCurr}}</b><br/>
storeIdExpanded: <b>{{storeIdExpanded}}</b>
</p>
</div>
<div class="span5">
<p class="nav-header">dayDataCollapse</p>{{dayDataCollapse}}</div>
</div>
<!-- END $scope.[model] updates -->
<!-- START TABLE -->
<div>
<table class="table table-hover table-condensed table-striped">
<thead class="levelOne">
<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" data-ng-switch on="dayDataCollapse[$index]">
<tr class="clickableRow"...
CSS
body {
padding: 10px;
padding-right:30px;
}
table {
border-collapse: separate;
border-spacing: 0 5px;
padding: 0px;
}
.levelOne {
background-color: #006DCC;
color: white;
}
.levelTwo {
background-color: #FF8C00;
color: black;
}
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.tableRowIndexExpandedCurr = "";
$scope.tableRowIndexExpandedPrev = "";
$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 (typeof $scope.dayDataCollapse === 'undefined') {
$scope.dayDataCollapseFn();
}
if ($scope.tableRowExpanded === false && $scope.tableRowIndexExpandedCurr === "" && $scope.storeIdExpanded === "") {
$scope.tableRowIndexExpandedPrev = "";
$scope.tableRowExpanded = true;
$scope.tableRowIndexExpandedCurr = index;
$scope.storeIdExpanded = storeId;
$scope.dayDataCollapse[index] = true;
} else if ($scope.tableRowExpanded === true) {
if ($scope.tableRowIndexExpandedCurr === index && $scope.storeIdExpanded === storeId) {
$scope.tableRowExpanded = false;
$scope.tableRowIndexExpandedCurr = "";
$scope.storeIdExpanded = "";
$scope.dayDataCollapse[index] = false;
} else {
$scope.tableRowIndexExpandedPrev = $scope.tableRowIndexExpandedCurr;
$scope.tableRowIndexExpandedCurr = index;
$scope.storeIdExpanded = storeId;
$scope.dayDataCollapse[$scope.tableRowIndexExpandedPrev] = false;
$scope.dayDataCollapse[$scope.tableRowIndexExpandedCurr] = true;
}
}
};
$scope.storeDataModel = {
"metadata": {
"storesInTotal": "25",
"storesInRepresentation": "6"
},
"storedata": [{
...