Files
netdisco/Netdisco/share/views/ajax/datatabledefaults.tt

44 lines
1.7 KiB
Plaintext

"processing": true,
"stateSave": true,
"pageLength": [% settings.table_pagesize %],
"lengthMenu": [% table_showrecordsmenu %],
"dom": '<"top"l<"nd_datatables-pager"p>f>rt<"bottom"><"clear">',
"language": {
"search": '_INPUT_',
"searchPlaceholder": 'Filter records...',
"lengthMenu": "Show _MENU_ records."
},
"rowCallback": function (row, data) {
// update in-cell content based on current sidebar settings
$('.nd_dynamic-dp').each( function() {
$(row).find('span.' + $(this).attr('id')).toggle( $(this).prop('checked') );
});
},
"stateSaveParams": function (settings, data) {
var pgtitle = update_page_title('[% tabname %]');
update_browser_history('[% tabname %]', pgtitle, '');
// TODO: would be nice to update CSV link too
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');
var col = datatable.column( id + ':name' );
if (col.length === 1) {
col.visible( $(this).prop('checked') );
data.columns[col.index()].visible = $(this).prop('checked');
}
});
}
// make sure filter is never saved
data.search.search = "";
// make sure paging position is not saved
data.start = 0;
}