mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-10 17:03:56 +08:00
Fix columns ordering when deleting custom fields [SCI-783]
This commit is contained in:
parent
e5a0ad9b23
commit
e414af2fc3
1 changed files with 8 additions and 0 deletions
|
@ -1147,6 +1147,8 @@ function changeToEditMode() {
|
|||
|
||||
form
|
||||
.on('ajax:success', function() {
|
||||
// Preserve columns ordering before destroying the table
|
||||
var colOrder = table.colReorder.order();
|
||||
// Destroy datatable
|
||||
table.destroy();
|
||||
|
||||
|
@ -1159,6 +1161,10 @@ function changeToEditMode() {
|
|||
// Remove column from table (=table header) & rows
|
||||
var th = originalHeader.find('#' + id);
|
||||
var index = th.index();
|
||||
var colIndex = $('#samples thead').find('#' + id).index();
|
||||
if (colIndex >= 0) {
|
||||
colOrder.splice(colIndex, 1);
|
||||
}
|
||||
th.remove();
|
||||
$('#samples tbody td:nth-child(' + (index + 1) + ')').remove();
|
||||
|
||||
|
@ -1175,6 +1181,8 @@ function changeToEditMode() {
|
|||
|
||||
// Re-initialize datatable
|
||||
table = dataTableInit();
|
||||
// Restore columns ordering
|
||||
table.colReorder.order(colOrder);
|
||||
loadColumnsNames();
|
||||
|
||||
// Hide modal
|
||||
|
|
Loading…
Reference in a new issue