mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-11 01:14:30 +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
|
form
|
||||||
.on('ajax:success', function() {
|
.on('ajax:success', function() {
|
||||||
|
// Preserve columns ordering before destroying the table
|
||||||
|
var colOrder = table.colReorder.order();
|
||||||
// Destroy datatable
|
// Destroy datatable
|
||||||
table.destroy();
|
table.destroy();
|
||||||
|
|
||||||
|
@ -1159,6 +1161,10 @@ function changeToEditMode() {
|
||||||
// Remove column from table (=table header) & rows
|
// Remove column from table (=table header) & rows
|
||||||
var th = originalHeader.find('#' + id);
|
var th = originalHeader.find('#' + id);
|
||||||
var index = th.index();
|
var index = th.index();
|
||||||
|
var colIndex = $('#samples thead').find('#' + id).index();
|
||||||
|
if (colIndex >= 0) {
|
||||||
|
colOrder.splice(colIndex, 1);
|
||||||
|
}
|
||||||
th.remove();
|
th.remove();
|
||||||
$('#samples tbody td:nth-child(' + (index + 1) + ')').remove();
|
$('#samples tbody td:nth-child(' + (index + 1) + ')').remove();
|
||||||
|
|
||||||
|
@ -1175,6 +1181,8 @@ function changeToEditMode() {
|
||||||
|
|
||||||
// Re-initialize datatable
|
// Re-initialize datatable
|
||||||
table = dataTableInit();
|
table = dataTableInit();
|
||||||
|
// Restore columns ordering
|
||||||
|
table.colReorder.order(colOrder);
|
||||||
loadColumnsNames();
|
loadColumnsNames();
|
||||||
|
|
||||||
// Hide modal
|
// Hide modal
|
||||||
|
|
Loading…
Reference in a new issue