diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java index 4ef6be8da..137493621 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/resourceload/ResourcesLoadPanel.java @@ -89,6 +89,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { private boolean refreshNameFilter = true; private int filterByNamePosition = 0; private int numberOfGroupsByName = 10; + private int lastSelectedName = 0; private PaginationType paginationType; private WeakReferencedListeners nameFilterListener = @@ -409,14 +410,30 @@ public class ResourcesLoadPanel extends HtmlMacroComponent { return groups.subList(filterByNamePosition, endPosition); } - public void onSelectFilterByName(Integer filterByNamePosition) { - if(paginationType != PaginationType.NONE) { - this.filterByNamePosition = filterByNamePosition.intValue(); - this.feedBackMessage = _("filtering by name"); - changeNameFilterWithFeedback(); + public void onSelectFilterByName(Combobox comboByName) { + if (comboByName.getSelectedItemApi() == null) { + resetComboByName(comboByName); + } else { + Integer filterByNamePosition = (Integer) comboByName + .getSelectedItemApi().getValue(); + if (paginationType != PaginationType.NONE) { + this.filterByNamePosition = filterByNamePosition.intValue(); + this.lastSelectedName = comboByName.getSelectedIndex(); + this.feedBackMessage = _("filtering by name"); + changeNameFilterWithFeedback(); + } } } + private void resetComboByName(Combobox comboByName) { + if (this.lastSelectedName == -1) { + comboByName.setSelectedIndex(0); + } else { + comboByName.setSelectedIndex(this.lastSelectedName); + } + comboByName.invalidate(); + } + private void changeNameFilterWithFeedback() { LongOperationFeedback.execute(componentOnWhichGiveFeedback, new ILongOperation() { diff --git a/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul b/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul index b5a2a76eb..c14f77010 100644 --- a/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul +++ b/ganttzk/src/main/resources/web/ganttz/zul/resourcesLoadLayout.zul @@ -48,7 +48,7 @@ resourcesLoadPanel = self; + onChange="resourcesLoadPanel.onSelectFilterByName(self)" />