<table id="ps-data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
  <thead>
    <tr>
      <th>Name</th>
      <th>Port</th>
      <th>Description</th>
      <th>Vlan</th>
    </tr>
  </thead>
</table>

<script type="text/javascript">
$(document).ready(function() {
  var table = $('#ps-data-table').dataTable({
    "processing": true,
    "stateSave": true,
    "pageLength": [% settings.table_pagesize %],
    "language": {
      "search": 'Filter records: '
    },
    "deferRender": true,
    "data": [% results %],
    "columns": [{
        "data": 'name',
        "render": function(data, type, row, meta) {
          return he.encode(data || '');
        }
      }, {
        "data": 'ip',
        "render": function(data, type, row, meta) {
          var ddns = '';
          if (row.device.dns || row.device.name) {
            ddns = ' (' + he.encode(row.device.dns || row.device.name)  + ')';
          }
          return '<a href="[% device_ports %]&q=' + encodeURIComponent(data) + '&f=' + encodeURIComponent(row.port) + '">' + he.encode(data) + '[' + he.encode(row.port) + ']</a>' + ddns;
        }
      }, {
        "data": 'descr',
        "render": function(data, type, row, meta) {
          return he.encode(data || '');
        }
      }, {
        "data": 'port_vlans.vlan',
        "render": function(data, type, row, meta) {
          return data || '';
        }
      }
    ]
  });
});</script>

