sidebar built from config, colvis defaults from sidebar
This commit is contained in:
@@ -11,23 +11,22 @@
|
||||
},
|
||||
"rowCallback": function (row, data) {
|
||||
// update in-cell content based on current sidebar settings
|
||||
[% FOREACH key IN settings.table_display.device.ports.keys %]
|
||||
if ($('#dp-data-table').DataTable().column('[% key %]:name').length === 0) {
|
||||
$(row).find('span.[% key %]').toggle( $("input[id='[% key %]']").prop('checked') );
|
||||
}
|
||||
[% END %]
|
||||
$('.nd_dynamic-dp').each( function() {
|
||||
$(row).find('span.' + $(this).attr('id')).toggle( $(this).prop('checked') );
|
||||
});
|
||||
},
|
||||
"stateLoadParams": function (settings, data) {
|
||||
// enforce config defaults for columns
|
||||
// TODO: allow state loading
|
||||
[% FOREACH key IN settings.table_display.device.ports.keys %]
|
||||
if (data.columns[$('#dp-data-table').DataTable().column('[% key %]:name').index()]) {
|
||||
data.columns[$('#dp-data-table').DataTable().column('[% key %]:name').index()].visible
|
||||
= [% (settings.table_display.device.ports.$key == 'on') ? 'true' : 'false' %];
|
||||
"stateSaveParams": function (settings, data) {
|
||||
var datatable = $('#[% tabname %]_pane').find('table').first().DataTable();
|
||||
// if no existing state, all columns default to visible.
|
||||
// on table load, state is saved... we can find out whether there was
|
||||
// loaded state, and if not, use this hook to set initial column
|
||||
// visibility.
|
||||
if (datatable.state.loaded() === null) {
|
||||
$('#[% tabname %]_form').find('input[type="checkbox"]').each( function() {
|
||||
var id = $(this).attr('id');
|
||||
if (datatable.column( id + ':name' ).length === 1) {
|
||||
datatable.column( id + ':name' ).visible( $(this).prop('checked') );
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("input[id='[% key %]']").prop('checked',
|
||||
[% (settings.table_display.device.ports.$key == 'on') ? 'true' : 'false' %]);
|
||||
}
|
||||
[% END %]
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
var freeDate = moment().subtract( [% params.age_num %], '[% params.age_unit %]' );
|
||||
var table = $('#dp-data-table').dataTable({
|
||||
$('#dp-data-table').dataTable({
|
||||
"deferRender": true,
|
||||
"order": [[ 1, "asc" ]],
|
||||
"colVis": {
|
||||
@@ -569,40 +569,6 @@ $(document).ready(function() {
|
||||
[% INCLUDE 'ajax/datatabledefaults.tt' -%]
|
||||
});
|
||||
|
||||
// display the column show/hide buttons in the sidebar
|
||||
var colvis = new $.fn.dataTable.ColVis( table );
|
||||
var columns = colvis.s.dt.aoColumns;
|
||||
|
||||
// first remove existing controls, in case indexes have changed
|
||||
$('#nd_column-controls').find('.nd_colvis-checkbox').remove();
|
||||
|
||||
if ( $.inArray( 'all', colvis.s.exclude ) === -1 ) {
|
||||
for ( var i=0, iLen=columns.length ; i<iLen ; i++ ) {
|
||||
if ( $.inArray( i, colvis.s.exclude ) === -1 ) {
|
||||
var button = colvis.dom.buttons.shift();
|
||||
if (columns[i]["name"] == "icon") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$(button).addClass('nd_colvis-checkbox');
|
||||
$(button).find('label').addClass('checkbox');
|
||||
$(button).find('input').attr('id', columns[i]["name"]);
|
||||
$(button).find('input').attr('name', columns[i]["name"]);
|
||||
|
||||
if (columns[i]["name"] == "c_neighbors") {
|
||||
$(button).find('span').text('Connected Devices');
|
||||
}
|
||||
|
||||
// need to re-activate tooltips on new content
|
||||
$(button).click(function() {
|
||||
$("[rel=tooltip]").tooltip({live: true});
|
||||
});
|
||||
|
||||
$('#nd_column-controls').append( button );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user