diff --git a/app/assets/javascripts/samples/sample_datatable.js.erb b/app/assets/javascripts/samples/sample_datatable.js.erb index 54586ee07..b072d8081 100644 --- a/app/assets/javascripts/samples/sample_datatable.js.erb +++ b/app/assets/javascripts/samples/sample_datatable.js.erb @@ -458,10 +458,7 @@ function onClickEdit() { }); // Adjust columns width in table header - table.columns.adjust(); - $('.dropdown-menu').parent().on('shown.bs.dropdown hidden.bs.dropdown', function () { - table.columns.adjust(); - }); + adjustTableHeader(); }, error: function (e, data, status, xhr) { if (e.status == 403) { @@ -746,7 +743,7 @@ function onClickAddSample() { $("select[name=sample_type_id]").selectpicker(); // Adjust columns width in table header - table.columns.adjust(); + adjustTableHeader(); }, error: function (e, eData, status, xhr) { if (e.status == 403) @@ -787,6 +784,14 @@ function createTdElement(content) { return td; } +// Adjust columns width in table header +function adjustTableHeader() { + table.columns.adjust(); + $('.dropdown-menu').parent().on('shown.bs.dropdown hidden.bs.dropdown', function () { + table.columns.adjust(); + }); +} + /** * Creates select dropdown for sample type * @param {Object[]} data List of sample types