Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
angular-fixed-table-header
Advanced tools
This module will allow you to scroll a table vertically while the header remains visible.
This software is provided free of charge and without restriction under the MIT License
This package is installable through the Bower package manager.
bower install angular-fixed-table-header --save
In your index.html
file, include the source file.
<script type="text/javascript" src="bower_components/angular-fixed-table-header/src/fixed-table-header.min.js"></script>
Include the fixed.table.header
module as a dependency in your application.
angular.module('myApp', ['fixed.table.header']);
In addition, this package may be installed using npm.
npm install angular-fixed-table-header --save
You may use Browserify to inject this module into your application.
angular.module('myApp', [require('angular-fixed-table-header')]);
Wrap the table in a element that will scroll vertically. Use the fix-head
attribute on a <thead>
element to prevent it from scrolling with the rest of the table.
A clone of the original <thead>
element will be moved outside the scroll container. To ensure valid HTML, the cloned <thead>
element will be wrapped in a copy of the <table>
element. The new <table>
element will be given the clone
class.
<div style="overflow: auto; max-height: 300px;">
<table>
<thead fix-head>
<tr>
<th>Name</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Email</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="contact in contacts">
<td>{{contact.name}}</td>
<td>{{contact.city}}</td>
<td>{{contact.state}}</td>
<td>{{contact.zip}}</td>
<td>{{contact.emial}}</td>
<td>{{contact.phone}}</td>
</tr>
</tbody>
</table>
</div>
main
property.ng-repeat
within the table header.<table>
element and empty its contents, then move it outside the scroll container and compile it.<thead>
element and append it to the original <table>
element and compile it.<thead>
element and append it to the cloned <table>
element.<th>
in the cloned <thead>
, set its width equal to the width of the original <th>
in the original <thead>
.<table>
element equal to negative the height of the original <thead>
element.<thead>
element.The advantage of this solution is the functionality of HTML tables is preserved.
thead
element; however, your thead
element may have multiple rows.If you are using this directive with my data table module then be aware that the progress indicator will still scroll with the rest of the table.
Use the following CSS to correct the borders.
table.clone thead tr:last-child th {
border-bottom: 1px rgba(0, 0, 0, 0.12) solid;
}
table.clone + md-table-container table tbody tr:first-child td {
border-top: none;
}
Why not reposition the original header instead of making a clone?
I'm taking advantage of the browsers ability to calculate the width of the columns. Otherwise the developer would have to manually set the width of each column like many other solutions.
Why not use a pure CSS solution?
CSS solutions often defeat the purpose of using a table in the first place. In addition, the solutions I've seen remove functionality from the table and require the developer to manually set the width of each column.
FAQs
Fixed table header directive.
The npm package angular-fixed-table-header receives a total of 834 weekly downloads. As such, angular-fixed-table-header popularity was classified as not popular.
We found that angular-fixed-table-header demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.