|
11 | 11 | <link rel="stylesheet" href="css/fixed-header.bootstrap.css"> |
12 | 12 | </head> |
13 | 13 | <body ng-app="myApp" ng-controller="myAppController" ng-cloak> |
14 | | -<nav class="navbar navbar-inverse"> |
| 14 | +<nav class="navbar navbar-inverse fixed-nav"> |
15 | 15 | <div class="container"> |
16 | 16 | <a href="#" class="navbar-brand">Angular Data Grid - Bootstrap Design</a> |
17 | 17 | <div class="navbar-form navbar-right" uib-dropdown> |
|
30 | 30 | </div> |
31 | 31 | </nav> |
32 | 32 | <div class="container"> |
33 | | - <div class="margin-bottom-basic"> |
34 | | - <h3>Angular Data Grid sample using out-of-box Bootstrap styling</h3> |
| 33 | + <div class="margin-bottom-basic padding-top-50"> |
| 34 | + <h2>Angular Data Grid sample using out-of-box Bootstrap styling</h2> |
35 | 35 | Features enabled: sorting, filtering (using both in-grid and external controls), sync with browser URLs, pagination and items-per-page functionality. |
36 | 36 | Angular UI Datepicker used for date controls, although you can use any other framework, plugin or styling. |
37 | 37 | <a href="https://github.com/angular-data-grid/angular-data-grid.github.io" target="_blank">Project GitHub</a> |
38 | 38 | </div> |
| 39 | + <hr> |
| 40 | + <h3>How To Freeze Table Header</h3> |
| 41 | + <h4>Using HTML Layout</h4> |
| 42 | + <div> |
| 43 | + <p>The first option is to split table header and table body between two tables |
| 44 | + And apply some css styles to these parts to sync table column's widths like in the steps below:</p> |
| 45 | + <ul> |
| 46 | + <li>Use the next styles applied to table body container to make it scrollable: <br> |
| 47 | + <code>.div-table-body { height: 600px; overflow-x: auto; overflow-y: scroll; } </code> |
| 48 | + </li> |
| 49 | + <li>Make sure that <code>th</code> elements have the same padding as <code>td</code> elements have.</li> |
| 50 | + <li>Use <code>padding-right</code> with the value of scroll bar width to make an offset for the table</li> |
| 51 | + <li>Use <code>width</code> attribute for columns to sync widths.</li> |
| 52 | + </ul> |
| 53 | + </div> |
| 54 | + <h4>Using Stand-alone Directive</h4> |
| 55 | + <div> |
| 56 | + <p>Another option is to use the built-in directive <code>fixed-header</code> that is included to the Data Grid like a separate module <code>dataGridUtils</code>.</p> |
| 57 | + <p>To make it work it is needed to perform next steps:</p> |
| 58 | + <ul> |
| 59 | + <li>Include script to your application: <br> |
| 60 | + <code><script src="bower_components/angular-data-grid/dist/dataGridUtils.min.js"></script></code> |
| 61 | + </li> |
| 62 | + <li>Include css stylesheets to your application: <br> |
| 63 | + <code><link rel="stylesheet" href="bower_components/angular-data-grid/css/fixedHeader/fixed-header.css"></code> |
| 64 | + </li> |
| 65 | + <li>Inject dataGridUtils dependency in your module: <br> |
| 66 | + <code>angular.module('myApp', ['dataGrid', ‘dataGridUtils.fixedHeader’])</code> |
| 67 | + </li> |
| 68 | + <li>Apply the directive <code>fixed-header</code> to the grid table: <br> |
| 69 | + <code><table class="table" fixed-header></code> |
| 70 | + </li> |
| 71 | + </ul> |
| 72 | + <p>The directive also has additional attribute called offset-from-element. |
| 73 | + It is needed if you already have some other elements that have fixed position above the table. |
| 74 | + In this case you need to pass a class or id of the very last element (if you have several) to this attribute |
| 75 | + to make the directive take |
| 76 | + into consideration that header needs to be fixed with offset from above elements.</p> |
| 77 | + <p>Example: <br> |
| 78 | + <code><table class="table" fixed-header offset-from-element |
| 79 | + =”.the-class-on-above-fixed-element”></code> <br> |
| 80 | + or <br> |
| 81 | + <code><table class="table" fixed-header offset-from-element |
| 82 | + =”=”#the-id-on-above-fixed-element”></code> |
| 83 | + </p> |
| 84 | + </div> |
| 85 | + <hr> |
39 | 86 | <h4>Additional Demos</h4> |
40 | 87 | <ul> |
41 | 88 | <li> |
@@ -160,7 +207,7 @@ <h4>Additional Demos</h4> |
160 | 207 | </form> |
161 | 208 | </div> |
162 | 209 | </div> |
163 | | - <table class="table table-bordered table-striped" fixed-header> |
| 210 | + <table class="table table-bordered table-striped" fixed-header offset-from-element=".fixed-nav"> |
164 | 211 | <thead> |
165 | 212 | <tr> |
166 | 213 | <th sortable="code" class="sortable"> |
|
0 commit comments