aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJonni Nakari <jonni@vaadin.com>2016-03-30 23:22:14 +0300
committerVaadin Code Review <review@vaadin.com>2016-05-31 13:02:42 +0000
commit68784363dca98529286420206b22a9a8881c70dc (patch)
tree4d00913073808eee1e1a935b3e4395c9d8ab7d1b /server
parent72c067a2d1913642b4cda591c2f76ad87d7279cb (diff)
downloadvaadin-framework-68784363dca98529286420206b22a9a8881c70dc.tar.gz
vaadin-framework-68784363dca98529286420206b22a9a8881c70dc.zip
Suggestion pop-up width API for ComboBox (#19685)
Added API setPopupWidth(String) to ComboBox. The suggestion pop-up now has three different width modes: 1. Legacy "null"-mode: width is determined by the longest item caption for each page. This looks & feels like the old implementation. This is the default mode 2. Relative to the ComboBox. e.g. 100% 3. fixed width using any CSS definition Change-Id: Id60a6996ee82726196b84d50c2d0d18a6cfb5ebf
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index b632cb0d8d..562173a9bf 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -121,6 +121,8 @@ public class ComboBox extends AbstractSelect implements
*/
private boolean scrollToSelectedItem = true;
+ private String suggestionPopupWidth = null;
+
/**
* If text input is not allowed, the ComboBox behaves like a pretty
* NativeSelect - the user can not enter any text and clicking the text
@@ -170,7 +172,7 @@ public class ComboBox extends AbstractSelect implements
/**
* Sets the input prompt - a textual prompt that is displayed when the
* select would otherwise be empty, to prompt the user for input.
- *
+ *
* @param inputPrompt
* the desired input prompt, or null to disable
*/
@@ -230,6 +232,11 @@ public class ComboBox extends AbstractSelect implements
target.addAttribute("pagelength", pageLength);
+ if (suggestionPopupWidth != null) {
+ target.addAttribute("suggestionPopupWidth",
+ suggestionPopupWidth);
+ }
+
target.addAttribute("filteringmode", getFilteringMode().toString());
// Paints the options and create array of selected id keys
@@ -875,6 +882,16 @@ public class ComboBox extends AbstractSelect implements
}
/**
+ * Returns the suggestion pop-up's width as a CSS string.
+ *
+ * @see #setPopupWidth
+ * @since 7.7
+ */
+ public String getPopupWidth() {
+ return suggestionPopupWidth;
+ }
+
+ /**
* Sets the page length for the suggestion popup. Setting the page length to
* 0 will disable suggestion popup paging (all items visible).
*
@@ -887,6 +904,20 @@ public class ComboBox extends AbstractSelect implements
}
/**
+ * Sets the suggestion pop-up's width as a CSS string. By using relative
+ * units (e.g. "50%") it's possible to set the popup's width relative to the
+ * ComboBox itself.
+ *
+ * @see #getPopupWidth()
+ * @since 7.7
+ * @param width the width
+ */
+ public void setPopupWidth(String width) {
+ suggestionPopupWidth = width;
+ markAsDirty();
+ }
+
+ /**
* Sets whether to scroll the selected item visible (directly open the page
* on which it is) when opening the combo box popup or not. Only applies to
* single select mode.