]>
Commit | Line | Data |
---|---|---|
31f18b77 FG |
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/dataTables.responsive.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="../../../../media/js/jquery.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": "age" }, | |
34 | { "data": "start_date" }, | |
35 | { "data": "salary" }, | |
36 | { "data": "extn" } | |
37 | ] | |
38 | } ); | |
39 | } ); | |
40 | ||
41 | ||
42 | ||
43 | </script> | |
44 | </head> | |
45 | ||
46 | <body class="dt-example"> | |
47 | <div class="container"> | |
48 | <section> | |
49 | <h1>Responsive example <span>Class control</span></h1> | |
50 | ||
51 | <div class="info"> | |
52 | <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 | |
53 | screen resolutions and the defaults are set for common devices:</p> | |
54 | ||
55 | <ul class="markdown"> | |
56 | <li><code>desktop</code> x >= 1024px</li> | |
57 | <li><code>tablet-l</code> (landscape) 768 <= x < 1024</li> | |
58 | <li><code>tablet-p</code> (portrait) 480 <= x < 768</li> | |
59 | <li><code>mobile-l</code> (landscape) 320 <= x < 480</li> | |
60 | <li><code>mobile-p</code> (portrait) x < 320</li> | |
61 | </ul> | |
62 | ||
63 | <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>, | |
64 | <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 | |
65 | 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 | |
66 | shown, and be shown at all sizes larger.</p> | |
67 | ||
68 | <p>Additionally, there are three special class names:</p> | |
69 | ||
70 | <ul class="markdown"> | |
71 | <li><code>all</code> - Always display</li> | |
72 | <li><code>none</code> - Don't display as a column, but show in the child row</li> | |
73 | <li><code>never</code> - Never display</li> | |
74 | <li><code>control</code> - Used for the <code>column</code> <a href= | |
75 | "//datatables.net/extensions/responsive/reference/option/responsive.details.type"><code class="option" title= | |
76 | "Responsive initialisation option">responsive.details.type<span>R</span></code></a> option.</li> | |
77 | </ul> | |
78 | ||
79 | <p>Please <a href="//datatables.net/extensions/responsive/">refer to the Responsive manual</a> for further details of these options.</p> | |
80 | ||
81 | <p>This example shows the <code>salary</code> column visible on a desktop only - <code>office</code> and <code>age</code> require a tablet, while the | |
82 | <code>position</code> column requires a phone in landscape or larger. The <code>name</code> column is always visible and the <code>start date</code> is never | |
83 | visible.</p> | |
84 | ||
85 | <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 | |
86 | <code>not-mobile</code> on two different columns would allow information to be formatted suitable for each device type.</p> | |
87 | </div> | |
88 | ||
89 | <div id="breakpoint"></div> | |
90 | ||
91 | <table id="example" class="display responsive" width="100%"> | |
92 | <thead> | |
93 | <tr> | |
94 | <th class="all">Name</th> | |
95 | <th class="min-phone-l">Position</th> | |
96 | <th class="min-tablet">Office</th> | |
97 | <th class="min-tablet">Age</th> | |
98 | <th class="never">Start date</th> | |
99 | <th class="desktop">Salary</th> | |
100 | <th class="none">Extn.</th> | |
101 | </tr> | |
102 | </thead> | |
103 | ||
104 | <tfoot> | |
105 | <tr> | |
106 | <th>Name</th> | |
107 | <th>Position</th> | |
108 | <th>Office</th> | |
109 | <th>Age</th> | |
110 | <th>Start date</th> | |
111 | <th>Salary</th> | |
112 | <th>Extn.</th> | |
113 | </tr> | |
114 | </tfoot> | |
115 | </table> | |
116 | ||
117 | <ul class="tabs"> | |
118 | <li class="active">Javascript</li> | |
119 | <li>HTML</li> | |
120 | <li>CSS</li> | |
121 | <li>Ajax</li> | |
122 | <li>Server-side script</li> | |
123 | </ul> | |
124 | ||
125 | <div class="tabs"> | |
126 | <div class="js"> | |
127 | <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() { | |
128 | $('#example').DataTable( { | |
129 | "ajax": "../../../../examples/ajax/data/objects.txt", | |
130 | "columns": [ | |
131 | { "data": "name" }, | |
132 | { "data": "position" }, | |
133 | { "data": "office" }, | |
134 | { "data": "age" }, | |
135 | { "data": "start_date" }, | |
136 | { "data": "salary" }, | |
137 | { "data": "extn" } | |
138 | ] | |
139 | } ); | |
140 | } );</code> | |
141 | ||
142 | <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p> | |
143 | ||
144 | <ul> | |
145 | <li><a href="../../../../media/js/jquery.js">../../../../media/js/jquery.js</a></li> | |
146 | <li><a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a></li> | |
147 | <li><a href="../../js/dataTables.responsive.js">../../js/dataTables.responsive.js</a></li> | |
148 | </ul> | |
149 | </div> | |
150 | ||
151 | <div class="table"> | |
152 | <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p> | |
153 | </div> | |
154 | ||
155 | <div class="css"> | |
156 | <div> | |
157 | <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 | |
158 | additional CSS used is shown below:</p><code class="multiline language-css"></code> | |
159 | </div> | |
160 | ||
161 | <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p> | |
162 | ||
163 | <ul> | |
164 | <li><a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a></li> | |
165 | <li><a href="../../css/dataTables.responsive.css">../../css/dataTables.responsive.css</a></li> | |
166 | </ul> | |
167 | </div> | |
168 | ||
169 | <div class="ajax"> | |
170 | <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 | |
171 | loaded.</p> | |
172 | </div> | |
173 | ||
174 | <div class="php"> | |
175 | <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 | |
176 | processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables | |
177 | documentation</a>.</p> | |
178 | </div> | |
179 | </div> | |
180 | </section> | |
181 | </div> | |
182 | ||
183 | <section> | |
184 | <div class="footer"> | |
185 | <div class="gradient"></div> | |
186 | ||
187 | <div class="liner"> | |
188 | <h2>Other examples</h2> | |
189 | ||
190 | <div class="toc"> | |
191 | <div class="toc-group"> | |
192 | <h3><a href="../initialisation/index.html">Basic initialisation</a></h3> | |
193 | <ul class="toc"> | |
194 | <li><a href="../initialisation/className.html">Class name</a></li> | |
195 | <li><a href="../initialisation/option.html">Configuration option</a></li> | |
196 | <li><a href="../initialisation/new.html">`new` constructor</a></li> | |
197 | <li><a href="../initialisation/ajax.html">Ajax data</a></li> | |
198 | <li><a href="../initialisation/default.html">Default initialisation</a></li> | |
199 | </ul> | |
200 | </div> | |
201 | ||
202 | <div class="toc-group"> | |
203 | <h3><a href="../styling/index.html">Styling</a></h3> | |
204 | <ul class="toc"> | |
205 | <li><a href="../styling/bootstrap.html">Bootstrap styling</a></li> | |
206 | <li><a href="../styling/foundation.html">Foundation styling</a></li> | |
207 | <li><a href="../styling/scrolling.html">Vertical scrolling</a></li> | |
208 | <li><a href="../styling/compact.html">Compact styling</a></li> | |
209 | </ul> | |
210 | </div> | |
211 | ||
212 | <div class="toc-group"> | |
213 | <h3><a href="./index.html">Display control</a></h3> | |
214 | <ul class="toc active"> | |
215 | <li><a href="./auto.html">Automatic column hiding</a></li> | |
216 | <li class="active"><a href="./classes.html">Class control</a></li> | |
217 | <li><a href="./init-classes.html">Assigned class control</a></li> | |
218 | <li><a href="./fixedHeader.html">With FixedHeader</a></li> | |
219 | <li><a href="./complexHeader.html">Complex headers (rowspan / colspan)</a></li> | |
220 | </ul> | |
221 | </div> | |
222 | ||
223 | <div class="toc-group"> | |
224 | <h3><a href="../child-rows/index.html">Child rows</a></h3> | |
225 | <ul class="toc"> | |
226 | <li><a href="../child-rows/disable-child-rows.html">Disable child rows</a></li> | |
227 | <li><a href="../child-rows/column-control.html">Column controlled child rows</a></li> | |
228 | <li><a href="../child-rows/right-column.html">Column control - right</a></li> | |
229 | <li><a href="../child-rows/whole-row-control.html">Whole row child row control</a></li> | |
230 | <li><a href="../child-rows/custom-renderer.html">Custom child row renderer</a></li> | |
231 | </ul> | |
232 | </div> | |
233 | </div> | |
234 | ||
235 | <div class="epilogue"> | |
236 | <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br> | |
237 | Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and <a href="http://www.datatables.net/plug-ins">plug-ins</a> | |
238 | which extend the capabilities of DataTables.</p> | |
239 | ||
240 | <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br> | |
241 | DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p> | |
242 | </div> | |
243 | </div> | |
244 | </div> | |
245 | </section> | |
246 | </body> | |
247 | </html> |