-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Items fetch callback #1923
Comments
I've tried implement suggestions for
But there is a problem with value conversion in |
Needs some improvements:
|
Jmix version: 2.1.999-SNAPSHOT |
Consider implementing com.vaadin.flow.data.provider.CallbackDataProvider instead of separate component
Solution
The
setItemsFetchCallback
method is added for the following components:ComboBox
EntityComboBox
MultiselectComboBox
MultiselectComboBoxPicker
XML
All components support an optional
itemsQuery
element that enables defining a query for selecting suggested values.The
itemsQuery
element for theEntityComboBox
has the following attributes:class
(required) - a full qualified name of an entity class.fetchPlan
- an optional attribute that specifies the fetch plan to be used for loading the queried entity.escapeValueForLike
- enables searching for the values that contain special symbols:%
,\
, etc. The default value isfalse
.searchStringFormat
- a string that contains a variable to be substituted with actual value byio.jmix.flowui.sys.substitutor.StringSubstitutor
. The default implementation delegates its work toorg.apache.commons.text.StringSubstitutor
.The
itemsQuery
element for theEntityComboBox
has the following nested elements:query
- an element that contains a JPQL queryfetchPlan
- an optional descriptor of inline fetch planThe
itemsQuery
element for theComboBox
has the following attributes:escapeValueForLike
- enables searching for the values that contain special symbols:%
,\
, etc. The default value isfalse
.searchStringFormat
- a string that contains a variable to be substituted with actual value byio.jmix.flowui.sys.substitutor.StringSubstitutor
. The default implementation delegates its work toorg.apache.commons.text.StringSubstitutor
.The
itemsQuery
element for theEntityComboBox
has the following nested element:query
- an element that contains a JPQL queryNote: there is no
entityClass
andfetchPlan
becauseComboBox
assumes that scalar values will be loaded. In case if entities useEntityComboBox
.The
itemsQuery
element for theMultiSelectComboBox
andMultiSelectComboBoxPicker
has the following attributes:class
(optional) - a full qualified name of an entity class.fetchPlan
- an optional attribute that specifies the fetch plan to be used for loading the queried entity.escapeValueForLike
- enables searching for the values that contain special symbols:%
,\
, etc. The default value isfalse
.searchStringFormat
- a string that contains a variable to be substituted with actual value byio.jmix.flowui.sys.substitutor.StringSubstitutor
. The default implementation delegates its work toorg.apache.commons.text.StringSubstitutor
.The
itemsQuery
element for theMultiSelectComboBox
andMultiSelectComboBoxPicker
has the following nested elements:query
- an element that contains a JPQL queryfetchPlan
- an optional descriptor of inline fetch planNote: Because both
MultiSelectComboBox
andMultiSelectComboBoxPicker
work with entities and scalar valuesitemsQuery
hasclass
attribute but its optional.View Controller
If
itemsQuery
is not defined, you should programmatically set the list of options usingsetItemsFetchCallback
.Note: Because the real work is delegated to
com.vaadin.flow.data.provider.HasLazyDataView#setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T,F>)
, theQueryTrace
instance is passed to thefetch
callback. As a result, there are several limitations:query.getOffset()
andquery.getLimit()
methods must be called, otherwise an exception is thrown.limit
value, otherwise an exception is thrown.The text was updated successfully, but these errors were encountered: