DataTables for VLAN inventory report
This commit is contained in:
@@ -1,24 +1,44 @@
|
||||
[% USE Number.Format %]
|
||||
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||
<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="nd_center-cell">VLAN ID</th>
|
||||
<th class="nd_center-cell">VLAN Name</th>
|
||||
<th class="nd_center-cell">Device Count</th>
|
||||
<th class="nd_center-cell">Port Count</th>
|
||||
<th>VLAN ID</th>
|
||||
<th>VLAN Name</th>
|
||||
<th>Device Count</th>
|
||||
<th>Port Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td><a class="nd_linkcell"
|
||||
href="[% uri_for('/search') %]?tab=vlan&q=[% row.vlan | uri %]">
|
||||
[% row.vlan | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.description %]</td>
|
||||
<td class="nd_center-cell">[% row.get_column('dcount') | format_number %]</td>
|
||||
<td class="nd_center-cell">[% row.get_column('pcount') | format_number %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var table = $('#data-table').dataTable({
|
||||
"deferRender": true,
|
||||
"data": [% results %],
|
||||
"columns": [
|
||||
{
|
||||
"data": 'vlan',
|
||||
"render": function(data, type, row, meta) {
|
||||
return '<a href="[% uri_for('/search') %]?tab=vlan&q=' + encodeURIComponent(data) + '">' + data + '</a>';
|
||||
}
|
||||
}, {
|
||||
"data": 'description',
|
||||
"render": function(data, type, row, meta) {
|
||||
return he.encode(data || '');
|
||||
}
|
||||
}, {
|
||||
"data": 'dcount',
|
||||
"searchable": false,
|
||||
"render": function(data, type, full, meta) {
|
||||
return data.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
}, {
|
||||
"data": 'pcount',
|
||||
"searchable": false,
|
||||
"render": function(data, type, full, meta) {
|
||||
return data.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[% USE CSV -%]
|
||||
[% CSV.dump([ 'VLAN ID' 'VLAN Name' 'Device Count' 'Port Count' ]) %]
|
||||
|
||||
[% WHILE (row = results.next) %]
|
||||
[% FOREACH row IN results %]
|
||||
[% mylist = [] %]
|
||||
[% mylist.push(row.vlan) %]
|
||||
[% mylist.push(row.description) %]
|
||||
[% mylist.push(row.get_column('dcount')) %]
|
||||
[% mylist.push(row.get_column('pcount')) %]
|
||||
[% mylist.push(row.dcount) %]
|
||||
[% mylist.push(row.pcount) %]
|
||||
[% CSV.dump(mylist) %]
|
||||
|
||||
[% END %]
|
||||
|
||||
Reference in New Issue
Block a user