From 22c2f659e8dc7915bc847e76ea99e79985ad2cd0 Mon Sep 17 00:00:00 2001 From: Justin Gray Date: Wed, 20 Jan 2016 19:42:41 -0600 Subject: [PATCH] Fixed the attachments table Fixed the sorting on the attachments table, there could be opportunity to clean this up a little. --- static/js/app/templates.js | 28 ++++++++++++++++++++++------ templates/templates.html | 8 ++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/static/js/app/templates.js b/static/js/app/templates.js index 85ece065..48dd0f1c 100644 --- a/static/js/app/templates.js +++ b/static/js/app/templates.js @@ -78,7 +78,14 @@ function deleteTemplate(idx){ } function attach(files){ - attachmentsTable = $("#attachmentsTable").DataTable(); + attachmentsTable = $("#attachmentsTable").DataTable({ + destroy: true, + "order": [[ 1, "asc" ]], + columnDefs: [ + { orderable: false, targets: "no-sort" }, + { sClass: "datatable_hidden", targets:[3,4]} + ] + }); $.each(files, function(i, file){ var reader = new FileReader(); /* Make this a datatable */ @@ -107,14 +114,23 @@ function edit(idx){ $("#attachmentsTable").show() attachmentsTable = null if ( $.fn.dataTable.isDataTable('#attachmentsTable') ) { - attachmentsTable = $('#attachmentsTable').DataTable(); + attachmentsTable = $('#attachmentsTable').DataTable({ + destroy: true, + "order": [[ 1, "asc" ]], + columnDefs: [ + { orderable: false, targets: "no-sort" }, + { sClass: "datatable_hidden", targets:[3,4]} + ] + }); } else { attachmentsTable = $("#attachmentsTable").DataTable({ - "aoColumnDefs" : [{ - "targets" : [3,4], - "sClass" : "datatable_hidden" - }] + destroy: true, + "order": [[ 1, "asc" ]], + columnDefs: [ + { orderable: false, targets: "no-sort" }, + { sClass: "datatable_hidden", targets:[3,4]} + ] }); } var template = {attachments:[]} diff --git a/templates/templates.html b/templates/templates.html index ac84b37f..5be682f1 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -102,11 +102,11 @@ - + - - - + + +
NameContentTypeContentType