[Koha-patches] [PATCH] Bug 7567 - Modify DataTables configuration

Owen Leonard oleonard at myacpl.org
Thu Mar 27 14:35:27 CET 2014


This follow-up corrects a JavaScript error by converting the sorting
configuration to be class-based
(http://wiki.koha-community.org/wiki/DataTables_HowTo#Sorting_dates_regardless_of_date_format_preference).

I have also changed the DataTables configuration to allow for pagination
and JS-based filtering.

To test, apply the patch and view the list of News items. Your browser
should report no JavaScript errors. Table sorting, pagination, and
filtering should work correctly.
---
 .../prog/en/modules/tools/koha-news.tt             |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
index 39cde86..842bed9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
@@ -9,14 +9,11 @@
     <script type="text/javascript">//<![CDATA[
     $(document).ready(function() {
         $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "sDom": 't',
             "aoColumnDefs": [
-                { "aTargets": [ 0,-1,-2 ], "bSortable": false, "bSearchable": false }
+                { "aTargets": [ 0,-1,-2 ], "bSortable": false },
+                { "aTargets": [ 0, -1 ], "bSearchable": false },
+                { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
             ],
-            "aoColumns": [
-                null,null,null,{ "sType": "title-string" },{ "sType": "title-string" },null,null,null
-            ],
-            "bPaginate": false
         }));
     });
     //]]>
@@ -62,7 +59,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
 
 [% UNLESS ( add_form ) %]
 <div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&lang=[% lang %]"><i class="icon-plus"></i> New entry</a>
+    <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&lang=[% lang %]"><i class="icon-plus"></i> New entry</a>
 </div>
 [% END %]
 
@@ -206,8 +203,8 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                         <th>Location</th>
                         <th>Library</th>
                         <th>Number</th>
-                        <th>Creation date</th>
-                        <th>Expiration date</th>
+                        <th class="title-string">Creation date</th>
+                        <th class="title-string">Expiration date</th>
                         <th>Title</th>
                         <th>News</th>
                         <th> </th>
-- 
1.7.9.5


More information about the Koha-patches mailing list