From: Charles Holbrow Date: Mon, 18 Mar 2013 22:57:58 +0000 (-0400) Subject: fixing bug for list display -- sort by note count now working X-Git-Tag: release-20150131~495 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e76731da1c6904fed9f8f6e93852b85f2651775d;p=oweals%2Fkarmaworld.git fixing bug for list display -- sort by note count now working --- diff --git a/karmaworld/templates/courses/course_list.html b/karmaworld/templates/courses/course_list.html index a3e3da0..9798c47 100644 --- a/karmaworld/templates/courses/course_list.html +++ b/karmaworld/templates/courses/course_list.html @@ -39,16 +39,29 @@ $(document).ready(function() { null, null, ], - // Add the 'Notes' label string to the notes row - 'fnRowCallback': function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { - $('td:eq(2)', nRow).append(' Notes'); - }, + "aoColumnDefs": [ { + "aTargets": [ 2 ], + "mData": function ( source, type, val ) { + //console.log(source); + if (type === 'set') { + source.count = val; + // Store the computed dislay and filter values for efficiency + source.count_display = val=="" ? "" : val+" Notes"; + return; + } + else if (type === 'display') { + return source.count_display; + } + // 'sort', 'type', 'filter' and undefined all just use the integer + return source.count; + } + } ], // Initial sorting 'aaSorting': [[2,'desc']] // Use out Ajax endpoing to populate the list //'sAjaxSource': "{% url 'api_course_list' %}" }); -$('.dataTables_filter input').attr("placeholder", "search courses"); + $('.dataTables_filter input').attr("placeholder", "search courses"); }); {% endblock %}