diff --git a/src/main/java/org/olat/core/gui/components/table/Table.java b/src/main/java/org/olat/core/gui/components/table/Table.java index 976f002d8ac40640f279f5425ec15d9987a4bfb7..a3b9271228fa52136a2dee3d91e7e30539c98627 100644 --- a/src/main/java/org/olat/core/gui/components/table/Table.java +++ b/src/main/java/org/olat/core/gui/components/table/Table.java @@ -651,11 +651,23 @@ public class Table extends AbstractComponent { return new ChoiceTableDataModel(isMultiSelect(), allCDs, columnOrder, getTranslator()); } - protected List<Integer> getDefaultVisibleColumns() { + /** + * Only use this for reset as it reorder the columns, remove the multi-select column + * and so on... + * + * @return The list of index (without multi select) and reorder to begin with 0 + */ + protected List<Integer> getDefaultVisibleColumnsToResetColumnsChoice() { List<Integer> indexList = new ArrayList<>(); for(ColumnDescriptor defaultVisibleCD:defaultVisibleCDs) { + if(defaultVisibleCD instanceof MultiSelectColumnDescriptor) continue; + int index = allCDs.indexOf(defaultVisibleCD); - if(index >= 0) { + if(isMultiSelect()) { + if(index > 0) { + indexList.add(index - 1); + } + } else { indexList.add(index); } } diff --git a/src/main/java/org/olat/core/gui/components/table/TableController.java b/src/main/java/org/olat/core/gui/components/table/TableController.java index c580d0f3334d79abe6117e37975466d5796920ae..ae2c5d439a8fc1950bed73532d8126f833aeac05 100644 --- a/src/main/java/org/olat/core/gui/components/table/TableController.java +++ b/src/main/java/org/olat/core/gui/components/table/TableController.java @@ -338,7 +338,7 @@ public class TableController extends BasicController { applyAndcheckChangedColumnsChoice(ureq, colsChoice.getSelectedRows()); } else if (event == Choice.EVNT_FORM_RESETED) { //sideeffect on table and prefs - List<Integer> visibleCols = table.getDefaultVisibleColumns(); + List<Integer> visibleCols = table.getDefaultVisibleColumnsToResetColumnsChoice(); applyAndcheckChangedColumnsChoice(ureq, visibleCols); } else { // cancelled cmc.deactivate();