From f6e2bbadaddb4be210d3bc504f278b9a1841e162 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Mon, 28 Oct 2013 18:00:41 +0100 Subject: [PATCH] MT#4287 preserve display setting rows in the local browser storage the number of rows in a datatables element is saved this is individually different for each page --- share/layout/body.tt | 5 +++++ share/templates/helpers/datatables.tt | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/share/layout/body.tt b/share/layout/body.tt index f45e4027f2..3a2954be74 100644 --- a/share/layout/body.tt +++ b/share/layout/body.tt @@ -180,6 +180,11 @@ $(function () { } }); } + + var my_pathname = window.location.pathname; + $('.dataTables_length > label > select').on('change', function (e) { + localStorage.setItem('ngcp_dt_entries'+my_pathname, $(this).find(":selected").text()); + }); }); diff --git a/share/templates/helpers/datatables.tt b/share/templates/helpers/datatables.tt index 182660ba4a..b472968efa 100644 --- a/share/templates/helpers/datatables.tt +++ b/share/templates/helpers/datatables.tt @@ -25,6 +25,10 @@ $.extend( $.fn.dataTableExt.oStdClasses, { } ); $(document).ready(function() { + var my_pathname = window.location.pathname; + var show_rows_storage = localStorage.getItem('ngcp_dt_entries'+my_pathname); + if (! show_rows_storage ) + show_rows_storage = 5; var [% helper.id_from_name %]_table = $('#[% helper.id_from_name %]_table') .dataTable( { "sDom": "<'row-fluid ngcp_dt_top_elements'lf>t<'row-fluid'<'pull-left'i><'pull-right'p>>", @@ -41,7 +45,7 @@ $(document).ready(function() { [% END %] "bSort": true, "bInfo": true, - "iDisplayLength": 5, + "iDisplayLength": show_rows_storage, 'iShowPages': 5, "sAjaxSource": "[% helper.ajax_uri %]", [% IF helper.column_sort -%]