| 9 |
lars |
1 |
<!DOCTYPE html>
|
|
|
2 |
<html>
|
|
|
3 |
<head>
|
|
|
4 |
<meta charset="utf-8">
|
|
|
5 |
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
|
|
|
6 |
<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
|
|
|
7 |
|
|
|
8 |
<title>Responsive example - Class control</title>
|
|
|
9 |
<link rel="stylesheet" type="text/css" href="../../../../media/css/jquery.dataTables.css">
|
|
|
10 |
<link rel="stylesheet" type="text/css" href="../../css/responsive.datatables.css">
|
|
|
11 |
<link rel="stylesheet" type="text/css" href="../../../../examples/resources/syntax/shCore.css">
|
|
|
12 |
<link rel="stylesheet" type="text/css" href="../../../../examples/resources/demo.css">
|
|
|
13 |
<style type="text/css" class="init">
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
</style>
|
|
|
17 |
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
|
|
|
18 |
<script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js"></script>
|
|
|
19 |
<script type="text/javascript" language="javascript" src="../../js/dataTables.responsive.js"></script>
|
|
|
20 |
<script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
|
|
|
21 |
<script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
|
|
|
22 |
<script type="text/javascript" language="javascript" class="init">
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
$(document).ready(function() {
|
|
|
27 |
$('#example').DataTable( {
|
|
|
28 |
"ajax": "../../../../examples/ajax/data/objects.txt",
|
|
|
29 |
"columns": [
|
|
|
30 |
{ "data": "name" },
|
|
|
31 |
{ "data": "position" },
|
|
|
32 |
{ "data": "office" },
|
|
|
33 |
{ "data": "start_date" },
|
|
|
34 |
{ "data": "salary" },
|
|
|
35 |
{ "data": "extn" }
|
|
|
36 |
]
|
|
|
37 |
} );
|
|
|
38 |
} );
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
</script>
|
|
|
43 |
</head>
|
|
|
44 |
|
|
|
45 |
<body class="dt-example">
|
|
|
46 |
<div class="container">
|
|
|
47 |
<section>
|
|
|
48 |
<h1>Responsive example <span>Class control</span></h1>
|
|
|
49 |
|
|
|
50 |
<div class="info">
|
|
|
51 |
<p>You can tell Responsive what columns to want to be visible on different devices through the use of class names on the columns. The breakpoints are horizontal
|
|
|
52 |
screen resolutions and the defaults are set for common devices:</p>
|
|
|
53 |
|
|
|
54 |
<ul class="markdown">
|
|
|
55 |
<li><code>desktop</code> x >= 1024px</li>
|
|
|
56 |
<li><code>tablet-l</code> (landscape) 768 <= x < 1024</li>
|
|
|
57 |
<li><code>tablet-p</code> (portrait) 480 <= x < 768</li>
|
|
|
58 |
<li><code>mobile-l</code> (landscape) 320 <= x < 480</li>
|
|
|
59 |
<li><code>mobile-p</code> (portrait) x < 320</li>
|
|
|
60 |
</ul>
|
|
|
61 |
|
|
|
62 |
<p>You may leave the <code>-[lp]</code> option from the end if you wish to just target all tablet or mobile devices. Additionally to may add <code>min-</code>,
|
|
|
63 |
<code>max-</code> or <code>not-</code> as a prefix to the class name to perform logic operations. For example <code>not-mobile</code> would cause a column to
|
|
|
64 |
appear as visible on desktop and tablet devices, while <code>min-tablet-l</code> would require at least a horizontal width of 768 for the browser window to be
|
|
|
65 |
shown, and be shown at all sizes larger.</p>
|
|
|
66 |
|
|
|
67 |
<p>Additionally, there are three special class names:</p>
|
|
|
68 |
|
|
|
69 |
<ul class="markdown">
|
|
|
70 |
<li><code>all</code> - Always display</li>
|
|
|
71 |
<li><code>none</code> - Don't display as a column, but show in the child row</li>
|
|
|
72 |
<li><code>never</code> - Never display</li>
|
|
|
73 |
<li><code>control</code> - Used for the <code>column</code> <a href="//datatables.net/reference/option/responsive.details.type"><code class="option" title=
|
|
|
74 |
"Responsive initialisation option">responsive.details.type</code></a> option.</li>
|
|
|
75 |
</ul>
|
|
|
76 |
|
|
|
77 |
<p>Please <a href="//datatables.net/extensions/responsive/">refer to the Responsive manual</a> for further details of these options.</p>
|
|
|
78 |
|
|
|
79 |
<p>This example shows the <code>salary</code> column visible on a desktop only - <code>office</code> requires a tablet, while the <code>position</code> column
|
|
|
80 |
requires a phone in landscape or larger. The <code>name</code> column is always visible and the <code>start date</code> is never visible.</p>
|
|
|
81 |
|
|
|
82 |
<p>This can be useful if you wish to change the format of the data shown on different devices, for example using a combination of <code>mobile</code> and
|
|
|
83 |
<code>not-mobile</code> on two different columns would allow information to be formatted suitable for each device type.</p>
|
|
|
84 |
</div>
|
|
|
85 |
|
|
|
86 |
<div id="breakpoint"></div>
|
|
|
87 |
|
|
|
88 |
<table id="example" class="display responsive" width="100%">
|
|
|
89 |
<thead>
|
|
|
90 |
<tr>
|
|
|
91 |
<th class="all">Name</th>
|
|
|
92 |
<th class="min-phone-l">Position</th>
|
|
|
93 |
<th class="min-tablet">Office</th>
|
|
|
94 |
<th class="never">Start date</th>
|
|
|
95 |
<th class="desktop">Salary</th>
|
|
|
96 |
<th class="none">Extn.</th>
|
|
|
97 |
</tr>
|
|
|
98 |
</thead>
|
|
|
99 |
|
|
|
100 |
<tfoot>
|
|
|
101 |
<tr>
|
|
|
102 |
<th>Name</th>
|
|
|
103 |
<th>Position</th>
|
|
|
104 |
<th>Office</th>
|
|
|
105 |
<th>Start date</th>
|
|
|
106 |
<th>Salary</th>
|
|
|
107 |
<th>Extn.</th>
|
|
|
108 |
</tr>
|
|
|
109 |
</tfoot>
|
|
|
110 |
</table>
|
|
|
111 |
|
|
|
112 |
<ul class="tabs">
|
|
|
113 |
<li class="active">Javascript</li>
|
|
|
114 |
<li>HTML</li>
|
|
|
115 |
<li>CSS</li>
|
|
|
116 |
<li>Ajax</li>
|
|
|
117 |
<li>Server-side script</li>
|
|
|
118 |
</ul>
|
|
|
119 |
|
|
|
120 |
<div class="tabs">
|
|
|
121 |
<div class="js">
|
|
|
122 |
<p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
|
|
|
123 |
$('#example').DataTable( {
|
|
|
124 |
"ajax": "../../../../examples/ajax/data/objects.txt",
|
|
|
125 |
"columns": [
|
|
|
126 |
{ "data": "name" },
|
|
|
127 |
{ "data": "position" },
|
|
|
128 |
{ "data": "office" },
|
|
|
129 |
{ "data": "start_date" },
|
|
|
130 |
{ "data": "salary" },
|
|
|
131 |
{ "data": "extn" }
|
|
|
132 |
]
|
|
|
133 |
} );
|
|
|
134 |
} );</code>
|
|
|
135 |
|
|
|
136 |
<p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
|
|
|
137 |
|
|
|
138 |
<ul>
|
|
|
139 |
<li><a href="//code.jquery.com/jquery-1.11.3.min.js">//code.jquery.com/jquery-1.11.3.min.js</a></li>
|
|
|
140 |
<li><a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li>
|
|
|
141 |
<li><a href="../../js/dataTables.responsive.js">../../js/dataTables.responsive.js</a></li>
|
|
|
142 |
</ul>
|
|
|
143 |
</div>
|
|
|
144 |
|
|
|
145 |
<div class="table">
|
|
|
146 |
<p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
|
|
|
147 |
</div>
|
|
|
148 |
|
|
|
149 |
<div class="css">
|
|
|
150 |
<div>
|
|
|
151 |
<p>This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The
|
|
|
152 |
additional CSS used is shown below:</p><code class="multiline language-css"></code>
|
|
|
153 |
</div>
|
|
|
154 |
|
|
|
155 |
<p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
|
|
|
156 |
|
|
|
157 |
<ul>
|
|
|
158 |
<li><a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li>
|
|
|
159 |
<li><a href="../../css/responsive.datatables.css">../../css/responsive.datatables.css</a></li>
|
|
|
160 |
</ul>
|
|
|
161 |
</div>
|
|
|
162 |
|
|
|
163 |
<div class="ajax">
|
|
|
164 |
<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is
|
|
|
165 |
loaded.</p>
|
|
|
166 |
</div>
|
|
|
167 |
|
|
|
168 |
<div class="php">
|
|
|
169 |
<p>The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side
|
|
|
170 |
processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
|
|
|
171 |
documentation</a>.</p>
|
|
|
172 |
</div>
|
|
|
173 |
</div>
|
|
|
174 |
</section>
|
|
|
175 |
</div>
|
|
|
176 |
|
|
|
177 |
<section>
|
|
|
178 |
<div class="footer">
|
|
|
179 |
<div class="gradient"></div>
|
|
|
180 |
|
|
|
181 |
<div class="liner">
|
|
|
182 |
<h2>Other examples</h2>
|
|
|
183 |
|
|
|
184 |
<div class="toc">
|
|
|
185 |
<div class="toc-group">
|
|
|
186 |
<h3><a href="../initialisation/index.html">Basic initialisation</a></h3>
|
|
|
187 |
<ul class="toc">
|
|
|
188 |
<li><a href="../initialisation/className.html">Class name</a></li>
|
|
|
189 |
<li><a href="../initialisation/option.html">Configuration option</a></li>
|
|
|
190 |
<li><a href="../initialisation/new.html">`new` constructor</a></li>
|
|
|
191 |
<li><a href="../initialisation/ajax.html">Ajax data</a></li>
|
|
|
192 |
<li><a href="../initialisation/default.html">Default initialisation</a></li>
|
|
|
193 |
</ul>
|
|
|
194 |
</div>
|
|
|
195 |
|
|
|
196 |
<div class="toc-group">
|
|
|
197 |
<h3><a href="../styling/index.html">Styling</a></h3>
|
|
|
198 |
<ul class="toc">
|
|
|
199 |
<li><a href="../styling/bootstrap.html">Bootstrap styling</a></li>
|
|
|
200 |
<li><a href="../styling/foundation.html">Foundation styling</a></li>
|
|
|
201 |
<li><a href="../styling/jqueryui.html">jQuery UI styling</a></li>
|
|
|
202 |
<li><a href="../styling/compact.html">Compact styling</a></li>
|
|
|
203 |
<li><a href="../styling/scrolling.html">Vertical scrolling</a></li>
|
|
|
204 |
</ul>
|
|
|
205 |
</div>
|
|
|
206 |
|
|
|
207 |
<div class="toc-group">
|
|
|
208 |
<h3><a href="./index.html">Display control</a></h3>
|
|
|
209 |
<ul class="toc active">
|
|
|
210 |
<li><a href="./auto.html">Automatic column hiding</a></li>
|
|
|
211 |
<li class="active"><a href="./classes.html">Class control</a></li>
|
|
|
212 |
<li><a href="./init-classes.html">Assigned class control</a></li>
|
|
|
213 |
<li><a href="./fixedHeader.html">With FixedHeader</a></li>
|
|
|
214 |
<li><a href="./complexHeader.html">Complex headers (rowspan / colspan)</a></li>
|
|
|
215 |
</ul>
|
|
|
216 |
</div>
|
|
|
217 |
|
|
|
218 |
<div class="toc-group">
|
|
|
219 |
<h3><a href="../child-rows/index.html">Child rows</a></h3>
|
|
|
220 |
<ul class="toc">
|
|
|
221 |
<li><a href="../child-rows/disable-child-rows.html">Disable child rows</a></li>
|
|
|
222 |
<li><a href="../child-rows/column-control.html">Column controlled child rows</a></li>
|
|
|
223 |
<li><a href="../child-rows/right-column.html">Column control - right</a></li>
|
|
|
224 |
<li><a href="../child-rows/whole-row-control.html">Whole row child row control</a></li>
|
|
|
225 |
<li><a href="../child-rows/custom-renderer.html">Custom child row renderer</a></li>
|
|
|
226 |
</ul>
|
|
|
227 |
</div>
|
|
|
228 |
</div>
|
|
|
229 |
|
|
|
230 |
<div class="epilogue">
|
|
|
231 |
<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
|
|
|
232 |
Additionally, there are a wide range of <a href="http://www.datatables.net/extensions">extensions</a> and <a href=
|
|
|
233 |
"http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.</p>
|
|
|
234 |
|
|
|
235 |
<p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
|
|
|
236 |
DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
|
|
|
237 |
</div>
|
|
|
238 |
</div>
|
|
|
239 |
</div>
|
|
|
240 |
</section>
|
|
|
241 |
</body>
|
|
|
242 |
</html>
|