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">
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">
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">
26 $(document).ready(function() {
27 $('#example').DataTable( {
28 "ajax": "../../../../examples/ajax/data/objects.txt",
31 { "data": "position" },
34 { "data": "start_date" },
46 <body class="dt-example">
47 <div class="container">
49 <h1>Responsive example <span>Class control</span></h1>
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>
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>
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>
68 <p>Additionally, there are three special class names:</p>
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>
79 <p>Please <a href="//datatables.net/extensions/responsive/">refer to the Responsive manual</a> for further details of these options.</p>
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
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>
89 <div id="breakpoint"></div>
91 <table id="example" class="display responsive" width="100%">
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>
118 <li class="active">Javascript</li>
122 <li>Server-side script</li>
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" }
142 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
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>
152 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
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>
161 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
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>
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
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>
185 <div class="gradient"></div>
188 <h2>Other examples</h2>
191 <div class="toc-group">
192 <h3><a href="../initialisation/index.html">Basic initialisation</a></h3>
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>
202 <div class="toc-group">
203 <h3><a href="../styling/index.html">Styling</a></h3>
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>
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>
223 <div class="toc-group">
224 <h3><a href="../child-rows/index.html">Child rows</a></h3>
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>
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>
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>