I'm repeating <tbody>
in my bootstrap table which has a fixed height of 140px
and have added a scroll if the data exceeds that height.
I'm finding difficulty in fixing the header with values 'Season 2018 2019 2020 2021' as I'm scrolling the table.Has anyone faced similar issue (while repeating )
angular.module('plunker', []);
angular.module('plunker').controller('MyCtrl', ['$scope', function($scope) {
$scope.data = {
'widget1': {
'1': 10,
'2': 5
},
'widget2': {
'4': 7,
'6': 6
}
};
$scope.seasons=[{
'season':'Winter',
'2018':3,
'2019':34,
'2020':43,
'2021':4,
},
{
'season':'Autumn',
'2018':3,
'2019':34,
'2020':43,
'2021':4,
},
{
'season':'Rainy',
'2018':3,
'2019':34,
'2020':43,
'2021':4,
},
{
'season':'Summer',
'2018':3,
'2019':34,
'2020':43,
'2021':4,
},
{
'season':'Spring',
'2018':3,
'2019':34,
'2020':43,
'2021':4,
},
{
'season':'Windy',
'2018':3,
'2019':34,
'2020':43,
'2021':4,
}]
}]);
.table-scroll-header-fix {
width:238px;
overflow-y: auto;
max-height: 140px;
}
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div class="table-scroll-header-fix" ng-controller="MyCtrl">
<table class="table table-responsive">
<thead>
<tr class="summary-table-header">
<th>Season</th>
<th>2018</th>
<th>2019</th>
<th>2020 </th>
<th>2021 </th>
</tr>
</thead>
<tbody ng-repeat="item in seasons">
<tr style="cursor:pointer">
<td>{{item.season}}</td>
<td>{{item.2017}}</td>
<td>{{item.2018}}</td>
<td>{{item.2019}}</td>
<td>{{item.2020}}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>