54 lines
2.0 KiB
Plaintext
54 lines
2.0 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 results...',
|
|
"lengthMenu": "Show _MENU_ rows."
|
|
},
|
|
"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();
|
|
var sidebarform = $('#[% tabname %]_form');
|
|
// 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) {
|
|
sidebarform.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');
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
// save sidebar settings
|
|
data["sidebarform"] = sidebarform.serializeArray();
|
|
}
|
|
|
|
// make sure filter is never saved
|
|
data.search.search = "";
|
|
// make sure paging position is not saved
|
|
data.start = 0;
|
|
},
|
|
"stateLoadParams": function (settings, data) {
|
|
// load all sidebar settings
|
|
var sidebarform = $('#[% tabname %]_form');
|
|
sidebarform.deserialize( data.sidebarform );
|
|
}
|