Fixed the attachments table

Fixed the sorting on the attachments table, there could be opportunity
to clean this up a little.
pull/87/head
Justin Gray 2016-01-20 19:42:41 -06:00
parent b9fd654f8a
commit 22c2f659e8
2 changed files with 26 additions and 10 deletions

View File

@ -78,7 +78,14 @@ function deleteTemplate(idx){
} }
function attach(files){ 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){ $.each(files, function(i, file){
var reader = new FileReader(); var reader = new FileReader();
/* Make this a datatable */ /* Make this a datatable */
@ -107,14 +114,23 @@ function edit(idx){
$("#attachmentsTable").show() $("#attachmentsTable").show()
attachmentsTable = null attachmentsTable = null
if ( $.fn.dataTable.isDataTable('#attachmentsTable') ) { 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 { else {
attachmentsTable = $("#attachmentsTable").DataTable({ attachmentsTable = $("#attachmentsTable").DataTable({
"aoColumnDefs" : [{ destroy: true,
"targets" : [3,4], "order": [[ 1, "asc" ]],
"sClass" : "datatable_hidden" columnDefs: [
}] { orderable: false, targets: "no-sort" },
{ sClass: "datatable_hidden", targets:[3,4]}
]
}); });
} }
var template = {attachments:[]} var template = {attachments:[]}

View File

@ -102,11 +102,11 @@
<table id="attachmentsTable" class="table"> <table id="attachmentsTable" class="table">
<thead> <thead>
<tr> <tr>
<th class="col-md-1"></th> <th class="col-md-1 no-sort"></th>
<th class="col-md-10">Name</th> <th class="col-md-10">Name</th>
<th class="col-md-1"></th> <th class="col-md-1 no-sort"></th>
<th class="datatable_hidden">Content</th> <th class="datatable_hidden no-sort">Content</th>
<th class="datatable_hidden">Type</th> <th class="datatable_hidden no-sort">Type</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>