<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
  <thead>
    <tr>
      <th>Device</th>
      <th class="nd_center-cell">Total Ports</th>
      <th class="nd_center-cell">In Use</th>
      <th class="nd_center-cell">Shutdown</th>
      <th class="nd_center-cell">Free</th>
    </tr>
  </thead>
</table>

<script type="text/javascript">
$(document).ready(function() {
    var table = $('#data-table').dataTable({
        "deferRender": true,
        "data": [% results | none %],
        "columns": [
           {
                "data": 'ip',
                "render": function(data, type, row, meta) {
                    return '<a href="[% device_ports | none %]&q=' + encodeURIComponent(data) + '">' + he.encode(row.dns || row.ip) + '</a>';
                }
            }, {
                "data": 'port_count',
                "searchable": false,
                "render": function(data, type, row, meta) {
                    return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                }
            }, {
                "data": 'ports_in_use',
                "searchable": false,
                "render": function(data, type, row, meta) {
                    return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                }
            }, {
                "data": 'ports_shutdown',
                "searchable": false,
                "render": function(data, type, row, meta) {
                    return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                }
            }, {
                "data": 'ports_free',
                "searchable": false,
                "render": function(data, type, row, meta) {
                    return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                }
            }
        ],
[% INCLUDE 'ajax/datatabledefaults.tt' -%]
    });

});
</script>
