jQuery Datatables responsive example

by oktaviardi pratama

HTML

<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.1/css/jquery.dataTables.css">
<script src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="//cdn.datatables.net/responsive/1.0.0/css/dataTables.responsive.css">
<script src="//cdn.datatables.net/responsive/1.0.0/js/dataTables.responsive.js"></script>
<table id="example" class="display" width="100%"></table>

CSS

table th:nth-child(3), td:nth-child(3) {
  display: none;
}

JavaScript

$(document).ready(function() {
    var dataSet = '[[12352435,"08:00","asdf","weihrtiweotj","STOP"],[12352435,"08:00","asdf","weihrtiweotj","RUNNING"]]';
 		dataSet = JSON.parse(dataSet)
$(document).ready(function() {
    $('#example').DataTable( {
        data: dataSet,
        columns: [
            { test: "Name" },
            { test: "Position" },
            { test: "Office" },
            { test: "Extn." },
            { test: "Start date" }
        ]
    } );
} );
} );