T
- the data typepublic class ComboBox<T> extends TriggerField<T> implements HasBeforeSelectionHandlers<T>, HasSelectionHandlers<T>, ExpandEvent.HasExpandHandlers, CollapseEvent.HasCollapseHandlers, BeforeQueryEvent.HasBeforeQueryHandlers<T>
setForceSelection(boolean)
to true.
When not forcing a selection (setForceSelection(boolean)
)
CellComponent.getValue()
can return null even if the user has typed text into the
field if that text cannot be tied to a model from from the combo's store. In
this case, you can use ValueBaseField.getText()
to get the fields string value.
The selection list's options are populated from any ListStore
. If the
selection list is not otherwise in a list store, you may find it easier to
use SimpleComboBox
.Field.FieldStyles
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasDirection.Direction
DEBUG_ID_PREFIX
Constructor and Description |
---|
ComboBox(ComboBoxCell<T> cell)
Creates a new combo box with the given cell.
|
ComboBox(ListStore<T> store,
LabelProvider<? super T> labelProvider)
Creates a combo box that renders all items with the given label provider.
|
ComboBox(ListStore<T> store,
LabelProvider<? super T> labelProvider,
ListView<T,?> listView)
Creates a combo box that renders the input value with the label provider.
|
ComboBox(ListStore<T> store,
LabelProvider<? super T> labelProvider,
ListView<T,?> listView,
TriggerFieldCell.TriggerFieldAppearance appearance)
Creates a combo box that renders the input value with the label provider.
|
ComboBox(ListStore<T> store,
LabelProvider<? super T> labelProvider,
SafeHtmlRenderer<T> renderer)
Creates a combo box that renders the input value with the label provider
and the drop down values with the renderer.
|
ComboBox(ListStore<T> store,
LabelProvider<? super T> labelProvider,
SafeHtmlRenderer<T> renderer,
TriggerFieldCell.TriggerFieldAppearance appearance)
Creates a combo box that renders the input value with the label provider
and the drop down values with the renderer.
|
ComboBox(ListStore<T> store,
LabelProvider<? super T> labelProvider,
TriggerFieldCell.TriggerFieldAppearance appearance)
Creates a combo box that renders all items with the given label provider.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addBeforeQueryHandler(BeforeQueryEvent.BeforeQueryHandler<T> handler)
Adds a
BeforeQueryEvent.BeforeQueryHandler handler for BeforeQueryEvent
events. |
HandlerRegistration |
addBeforeSelectionHandler(BeforeSelectionHandler<T> handler) |
HandlerRegistration |
addCollapseHandler(CollapseEvent.CollapseHandler handler)
Adds a
CollapseEvent.CollapseHandler handler for CollapseEvent
events. |
HandlerRegistration |
addExpandHandler(ExpandEvent.ExpandHandler handler)
Adds a
ExpandEvent.ExpandHandler handler for ExpandEvent events. |
HandlerRegistration |
addSelectionHandler(SelectionHandler<T> handler) |
void |
clear()
Clears the value from the field.
|
void |
collapse()
Hides the dropdown list if it is currently expanded.
|
void |
doQuery(String query,
boolean force)
Execute a query to filter the dropdown list.
|
void |
expand()
Expands the dropdown list if it is currently hidden.
|
String |
getAllQuery()
Returns the all query.
|
ComboBoxCell<T> |
getCell()
Get the
Cell wrapped by this widget. |
LabelProvider<? super T> |
getLabelProvider()
Returns the combo's label provider.
|
ListView<T,?> |
getListView()
Returns the combo's list view.
|
Loader<?,?> |
getLoader()
Returns the combo's loader.
|
int |
getMaxHeight()
Returns the dropdown list's max height.
|
int |
getMinChars()
Returns the minimum characters used for autocomplete and typeahead.
|
int |
getMinListWidth()
Returns the dropdown list's minimum width.
|
int |
getPageSize()
Returns the page size.
|
int |
getQueryDelay()
Returns the query delay.
|
ListStore<T> |
getStore()
Returns the combo's list store.
|
ComboBoxCell.TriggerAction |
getTriggerAction()
Returns the trigger action.
|
int |
getTypeAheadDelay()
Returns the type ahead delay in milliseconds.
|
boolean |
isExpanded()
Returns true if the dropdown is expanded.
|
boolean |
isForceSelection()
Returns true if the field's value is forced to one of the value in the
list.
|
boolean |
isTypeAhead()
Returns true if type ahead is enabled.
|
boolean |
isUseQueryCache()
Returns the state if the query cache is used or not.
|
void |
select(int index)
Select an item in the dropdown list by its numeric index in the list.
|
void |
select(T item)
Select an item in the dropdown list.
|
void |
setAllQuery(String allQuery)
The text query to send to the server to return all records for the list
with no filtering (defaults to '').
|
void |
setExpanded(boolean expand)
Sets the panel's expand state.
|
void |
setForceSelection(boolean forceSelection)
Sets whether the combo's value is restricted to one of the values in the
list, false to allow the user to set arbitrary text into the field
(defaults to false).
|
void |
setLoader(Loader<?,?> loader)
Sets the comobo's loader.
|
void |
setLoadingHtml(SafeHtml loadingHtml)
Sets the html loading text to be displayed during a load request.
|
void |
setLoadingText(String loadingText)
Sets the text loading text to be displayed during a load request.
|
void |
setMaxHeight(int maxHeight)
Sets the maximum height in pixels of the dropdown list before scrollbars
are shown (defaults to 300).
|
void |
setMinChars(int minChars)
Sets the minimum number of characters the user must type before
autocomplete and typeahead active (defaults to 4 if remote, or 0 if local).
|
void |
setMinListWidth(int minListWidth)
Sets the minimum width of the dropdown list in pixels (defaults to 70, will
be ignored if listWidth has a higher value).
|
void |
setPageSize(int pageSize)
Sets the page size.
|
void |
setQueryDelay(int queryDelay)
The length of time in milliseconds to delay between the start of typing and
sending the query to filter the dropdown list.
|
void |
setStore(ListStore<T> store)
Sets the combo's store.
|
void |
setTriggerAction(ComboBoxCell.TriggerAction triggerAction)
The action to execute when the trigger field is activated.
|
void |
setTypeAhead(boolean typeAhead)
True to populate and autoselect the remainder of the text being typed after
a configurable delay (
setTypeAheadDelay(int) ) if it matches a known
value (defaults to false) |
void |
setTypeAheadDelay(int typeAheadDelay)
The length of time in milliseconds to wait until the typeahead text is
displayed if typeAhead = true (defaults to 250).
|
void |
setUseQueryCache(boolean useQueryCache)
Set this to false to disable the last query cache (defaults to true).
|
addTriggerClickHandler, isEditable, isFinishEditOnEnter, isMonitorTab, setEditable, setFinishEditOnEnter, setHideTrigger, setMonitorTab
addChangeHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addParseErrorHandler, getCurrentValue, getCursorPos, getDirection, getDirectionEstimator, getEmptyText, getPropertyEditor, getSelectedText, getSelectionLength, getText, getValueOrThrow, isAllowBlank, isClearValueOnParseError, isCurrentValid, isCurrentValid, isReadOnly, isSelectOnFocus, select, selectAll, setAllowBlank, setClearValueOnParseError, setCursorPos, setDirection, setDirectionEstimator, setDirectionEstimator, setEmptyText, setId, setPropertyEditor, setReadOnly, setSelectionRange, setSelectOnFocus, setTabIndex, setText, setValue, validateCurrent
addInvalidHandler, addValidator, addValidHandler, addValueChangeHandler, clearInvalid, finishEditing, flush, forceInvalid, getErrors, getErrorSupport, getName, getOriginalValue, getValidateOnBlur, getValidationDelay, getValidators, isAutoValidate, isEditing, isValid, isValid, markInvalid, onBrowserEvent, onPropertyChange, removeValidator, reset, setAutoValidate, setDelegate, setErrorSupport, setName, setOriginalValue, setValidateOnBlur, setValidationDelay, setValue, showErrors, validate, validate
getElement, getKeyProvider, getValue, redraw, setValue
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disable, disableEvents, enable, enableEvents, fireEvent, focus, getData, getFocusSupport, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setToolTip, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
fireEvent
getValue
addBlurHandler
public ComboBox(ComboBoxCell<T> cell)
cell
- the cell@UiConstructor public ComboBox(ListStore<T> store, LabelProvider<? super T> labelProvider)
store
- the store containing the data that can be selectedlabelProvider
- converts the current model type into a string value to
display in the text boxpublic ComboBox(ListStore<T> store, LabelProvider<? super T> labelProvider, ListView<T,?> listView)
store
- the store containing the data that can be selectedlabelProvider
- converts the current model type into a string value to
display in the text boxlistView
- the list viewpublic ComboBox(ListStore<T> store, LabelProvider<? super T> labelProvider, ListView<T,?> listView, TriggerFieldCell.TriggerFieldAppearance appearance)
store
- the store containing the data that can be selectedlabelProvider
- converts the current model type into a string value to
display in the text boxlistView
- the list viewappearance
- the appearancepublic ComboBox(ListStore<T> store, LabelProvider<? super T> labelProvider, SafeHtmlRenderer<T> renderer)
store
- the store containing the data that can be selectedlabelProvider
- converts the current model type into a string value to
display in the text boxrenderer
- draws the current model as html in the drop downpublic ComboBox(ListStore<T> store, LabelProvider<? super T> labelProvider, SafeHtmlRenderer<T> renderer, TriggerFieldCell.TriggerFieldAppearance appearance)
store
- the store containing the data that can be selectedlabelProvider
- converts the current model type into a string value to
display in the text boxrenderer
- draws the current model as html in the drop downappearance
- the appearancepublic ComboBox(ListStore<T> store, LabelProvider<? super T> labelProvider, TriggerFieldCell.TriggerFieldAppearance appearance)
store
- the store containing the data that can be selectedlabelProvider
- converts the current model type into a string value to
display in the text boxappearance
- the appearancepublic HandlerRegistration addBeforeQueryHandler(BeforeQueryEvent.BeforeQueryHandler<T> handler)
BeforeQueryEvent.HasBeforeQueryHandlers
BeforeQueryEvent.BeforeQueryHandler
handler for BeforeQueryEvent
events.addBeforeQueryHandler
in interface BeforeQueryEvent.HasBeforeQueryHandlers<T>
handler
- the handlerpublic HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<T> handler)
addBeforeSelectionHandler
in interface HasBeforeSelectionHandlers<T>
public HandlerRegistration addCollapseHandler(CollapseEvent.CollapseHandler handler)
CollapseEvent.HasCollapseHandlers
CollapseEvent.CollapseHandler
handler for CollapseEvent
events.addCollapseHandler
in interface CollapseEvent.HasCollapseHandlers
handler
- the handlerpublic HandlerRegistration addExpandHandler(ExpandEvent.ExpandHandler handler)
ExpandEvent.HasExpandHandlers
ExpandEvent.ExpandHandler
handler for ExpandEvent
events.addExpandHandler
in interface ExpandEvent.HasExpandHandlers
handler
- the handlerpublic HandlerRegistration addSelectionHandler(SelectionHandler<T> handler)
addSelectionHandler
in interface HasSelectionHandlers<T>
public void clear()
IsField
clear
in interface IsField<T>
clear
in class ValueBaseField<T>
to remove validation messages
,
to restore to original value and remove validation messages
public void collapse()
public void doQuery(String query, boolean force)
query
- the queryforce
- true to force the query to execute even if there are currently
fewer characters in the field than the minimum specified by the
minChars config option. It also clears any filter previously saved
in the current storepublic void expand()
public String getAllQuery()
public ComboBoxCell<T> getCell()
CellComponent
Cell
wrapped by this widget.getCell
in class TriggerField<T>
Cell
being wrappedpublic LabelProvider<? super T> getLabelProvider()
public Loader<?,?> getLoader()
public int getMaxHeight()
public int getMinChars()
public int getMinListWidth()
public int getPageSize()
public ComboBoxCell.TriggerAction getTriggerAction()
public int getTypeAheadDelay()
public boolean isUseQueryCache()
public int getQueryDelay()
public boolean isExpanded()
public boolean isForceSelection()
public boolean isTypeAhead()
public void select(int index)
index
- the index of the item to selectpublic void select(T item)
item
- the item to selectpublic void setAllQuery(String allQuery)
allQuery
- the all querypublic void setExpanded(boolean expand)
expand
- true true to expand
public void setForceSelection(boolean forceSelection)
forceSelection
- true to force selectionpublic void setLoader(Loader<?,?> loader)
loader
- the loaderpublic void setMaxHeight(int maxHeight)
maxHeight
- the max hieghtpublic void setLoadingHtml(SafeHtml loadingHtml)
setLoader(Loader)
has to be set for this use.
loadingHtml
- the loading htmlpublic void setLoadingText(String loadingText)
setLoader(Loader)
has to be set for this use.
loadingText
- the loading textpublic void setMinChars(int minChars)
minChars
- minimum number of characters before autocomplete and
typeahead are activepublic void setMinListWidth(int minListWidth)
minListWidth
- the min widthpublic void setPageSize(int pageSize)
pageSize
- the page sizepublic void setStore(ListStore<T> store)
store
- the storepublic void setTriggerAction(ComboBoxCell.TriggerAction triggerAction)
ComboBoxCell.TriggerAction.ALL
to run the query specified by the allQuery which
can be set using setAllQuery(String)
(defaults to
ComboBoxCell.TriggerAction.QUERY
).triggerAction
- the trigger actionpublic void setTypeAhead(boolean typeAhead)
setTypeAheadDelay(int)
) if it matches a known
value (defaults to false)typeAhead
- true to enable type aheadpublic void setTypeAheadDelay(int typeAheadDelay)
typeAheadDelay
- the type ahead delaypublic void setUseQueryCache(boolean useQueryCache)
useQueryCache
- the useQueryCache to setpublic void setQueryDelay(int queryDelay)
queryDelay
- the query delayCopyright © 2015. All rights reserved.