Skip to content

Commit ac2bfcd

Browse files
committed
Fix Issue #29: Added documentation to material sample
1 parent cfbd314 commit ac2bfcd

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

demo/fixed-header/angular-md-grid.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,59 @@ <h4>Angular Data Grid sample using Material Design styling</h4>
4747
grid styling.
4848
<a href="https://github.com/angular-data-grid/angular-data-grid.github.io"
4949
target="_blank">Project GitHub</a></p>
50+
51+
<hr>
52+
<h3>How To Freeze Table Header</h3>
53+
<h4>Using HTML Layout</h4>
54+
<div>
55+
<p>The first option is to split table header and table body between two tables
56+
And apply some css styles to these parts to sync table column's widths like in the steps below:</p>
57+
<ul>
58+
<li>Use the next styles applied to table body container to make it scrollable: <br>
59+
<code>.div-table-body { height: 600px; overflow-x: auto; overflow-y: scroll; } </code>
60+
</li>
61+
<li>Make sure that <code>th</code> elements have the same padding as <code>td</code> elements have.</li>
62+
<li>Use <code>padding-right</code> with the value of scroll bar width to make an offset for the table</li>
63+
<li>Use <code>width</code> attribute for columns to sync widths.</li>
64+
</ul>
65+
</div>
66+
<h4>Using Stand-alone Directive</h4>
67+
<div>
68+
<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>
69+
<p>To make it work it is needed to perform next steps:</p>
70+
<ul>
71+
<li>Include script to your application: <br>
72+
<code>&lt;script src="bower_components/angular-data-grid/dist/dataGridUtils.min.js"&gt;&lt;/script&gt;</code>
73+
</li>
74+
<li>Include css stylesheets to your application: <br>
75+
<code>&lt;link rel="stylesheet" href="bower_components/angular-data-grid/css/fixedHeader/fixed-header.css"&gt;</code>
76+
</li>
77+
<li>Inject dataGridUtils dependency in your module: <br>
78+
<code>angular.module('myApp', ['dataGrid', ‘dataGridUtils.fixedHeader’])</code>
79+
</li>
80+
<li>Apply the directive <code>fixed-header</code> to the grid table: <br>
81+
<code>&lt;table class="table" fixed-header&gt;</code>
82+
</li>
83+
</ul>
84+
<p>The directive also has additional attribute called offset-from-element.
85+
It is needed if you already have some other elements that have fixed position above the table.
86+
In this case you need to pass a class or id of the very last element (if you have several) to this attribute
87+
to make the directive take
88+
into consideration that header needs to be fixed with offset from above elements.</p>
89+
<p>Example: <br>
90+
<code>&lt;table class="table" fixed-header offset-from-element
91+
=”.the-class-on-above-fixed-element”&gt;</code> <br>
92+
or <br>
93+
<code>&lt;table class="table" fixed-header offset-from-element
94+
=”=”#the-id-on-above-fixed-element”&gt;</code>
95+
</p>
96+
<br>
97+
<p>To make it work for material design it is needed to not use md-content because of the fact that scroll event doesn't work in this case. <br>
98+
More Information could be found <a href="https://github.com/angular/material/issues/6657">here</a>. The issue in closed status but seems to be
99+
it's not fixed yet.
100+
</p>
101+
</div>
102+
<hr>
50103
</div>
51104
<hr>
52105
<div layout-gt-xs="row" layout-xs="column" layout-align="stretch center">

0 commit comments

Comments
 (0)