dataTable.fnFilter($(this).val());
});
+ function sortDirection(col) {
+ if (col == 3) {
+ return 'asc';
+ } else {
+ return 'desc';
+ }
+ }
+
// wire up sort chooser
$('select.course-sort').change(function() {
- dataTable.fnSort([[$(this).val(), 'desc']]);
+ var sortCol = $(this).val();
+ dataTable.fnSort([[sortCol, sortDirection(sortCol)]]);
});
// sort by current value of sort chooser, since
// the browser may change this from our default
- dataTable.fnSort([[$('select.course-sort').val(), 'desc']]);
+ var sortCol = $('select.course-sort').val();
+ dataTable.fnSort([[sortCol, sortDirection(sortCol)]]);
});
<option value="0">Date</option>
<option value="1">Number of Notes</option>
<option value="2" selected>Popularity</option>
+ <option value="3">School</option>
</select>
</div>
</div>
<table id="data_table_list">
<thead class="hide">
<tr>
- <th class="no-display" id="data-table-date"> Date </th>
- <th class="no-display" id="data-table-note-count"> # Notes </th>
- <th class="no-display" id="data-table-thanks"> Popularity </th>
- <th class="no-display" id="data-table-upload"> Course </th>
+ <th class="no-display" id="data-table-date">Date</th>
+ <th class="no-display" id="data-table-note-count"># Notes</th>
+ <th class="no-display" id="data-table-thanks">Popularity</th>
+ <th class="no-display" id="data-table-school">School</th>
+ <th class="no-display" id="data-table-course">Course</th>
</tr>
</thead>
<tbody>
<td class="hide">{{ course.updated_at|date:"U" }}</td>
<td class="hide">{{ course.file_count|stringformat:"010g" }}</td>
<td class="hide">{{ course.get_popularity|stringformat:"010g" }}</td>
+ {% if course.school %}
+ <td class="hide">{{ course.school.name }}</td>
+ {% else %}
+ <td class="hide">{{ course.department.school.name }}</td>
+ {% endif %}
<td class="small-12 columns">
<div class="data-table-entry">