Bug 42190: Add DataTables to report results

This is a POC (i.e. not ready for inclusion yet)
It adds a "Open in DataTables" button in the toolbar, that will refetch
the report (with a limit=100000, that needs to be configurable, how?)
and load the results in a kohaTable (DataTables)

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2026-03-27 12:49:34 +01:00 committed by Lucas Gass
parent e7b258bdb7
commit 97469d1a0d
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 21 additions and 0 deletions

View File

@ -178,6 +178,11 @@
>
[% END %]
</div>
<div class="btn-group">
<a class="btn btn-default fetch_dt_data" href="/cgi-bin/koha/reports/guided_reports.pl?id=[% id | html %]&amp;op=run&amp;reportname=[% name |uri %][% PROCESS params %]&amp;limit=100000&amp;dt=1"
><i class="fa fa-table"></i> Open in DataTables</a
>
</div>
[% END %]
[% END %]
</div>

View File

@ -1813,6 +1813,9 @@
var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
const tables = [% To.json(tables || []) | $raw %];
const open_in_dt = [% dt ? 1 : 0 | html %];
const execute = [% execute ? 1 : 0 | html %];
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
// if the report param form has multiselects override default form submission
@ -2242,6 +2245,18 @@
delColumn();
});
if (open_in_dt && execute && !has_errors) {
let columns = [];
$.each(header_row, function (index, value) {
columns.push({
cannot_be_modified: 0,
cannot_be_toggled: 0,
is_hidden: 0,
});
});
let report_table_settings = { columns };
$("#report_results").kohaTable({}, report_table_settings);
}
if (saved1) {
var rtable = $("#table_reports").kohaTable(
{

View File

@ -797,6 +797,7 @@ if ( $op eq 'run' ) {
$template->param(
'limit' => $limit,
'id' => $report_id,
dt => scalar $input->param('dt'),
);
my ( $sql, $original_sql, $type, $name, $notes );