Skip to content

Commit

Permalink
Support showing all rows as a length option in DataTables
Browse files Browse the repository at this point in the history
By adding -1 to datatables-lengthMenu, all rows can be shown
  • Loading branch information
alistair3149 committed Nov 27, 2024
1 parent a445d21 commit 647c5ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@
'ext.srf.widgets'
],
'messages' => [
'allmessages-filter-all',
'srf-ui-datatables-label-conditions',
'srf-ui-datatables-label-parameters',
'srf-ui-datatables-label-filters',
Expand Down
8 changes: 8 additions & 0 deletions formats/datatables/resources/ext.srf.formats.datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@
});
}

// Replace -1 in lengthMenu with 'all' label
var showAll = options.lengthMenu.indexOf( -1 );
if ( showAll !== -1 ) {
var labels = options.lengthMenu.slice();
labels[showAll] = mw.msg( 'allmessages-filter-all' ); // stealing MW core messages :D
options.lengthMenu = [ options.lengthMenu, labels ];
}

var query = data.query.ask;
var printouts = table.data("printouts");
var queryString = query.conditions;
Expand Down

0 comments on commit 647c5ba

Please sign in to comment.