Files
netdisco/Netdisco/share/views/ajax/datatabledefaults.tt
2014-10-25 19:19:56 +01:00

33 lines
1.3 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 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') );
}
});
}
}