nipunaw
(Nipuna Wijesiri)
August 9, 2023, 5:07am
1
I have the following filtration implemented from a comboBox. Is it possible to make this filtration for multiple selections from a comboBox?
<propertyFilter id="licenseFilter" property="license.name" operation="EQUAL" dataLoader="organizationsDl" visible="false"/>
<comboBox id="licenseCombo" allowCustomValue="false"/>
@ViewComponent
private ComboBox<String> licenseCombo;
@ViewComponent
private PropertyFilter licenseFilter;
private List<String> getLicenses(){
return dataManager.load(License.class).all().list().stream().map(License::getName).toList();
}
@Subscribe("licenseCombo")
public void onLicenseComboComponentValueChange(final AbstractField.ComponentValueChangeEvent<JmixComboBox, Object> event) {
licenseFilter.setValue(event.getValue());
}
@Subscribe
protected void onInit(InitEvent event) {
licenseCombo.setItems(getLicenses());
}
d.kremnev
(Dmitriy Kremnev)
August 9, 2023, 11:05am
3
Hi!
This is currently not possible, as there is no IN operator for the propertyFilter component.
Framework issue attached: Implement IN and DATE_INTERVAL operations in PropertyFilter · Issue #1442 · jmix-framework/jmix · GitHub
Also, you don’t have to manually bind the component to the propertyFilter, in your case.
The propertyFilter can use a custom component to input values automatically.
Just insert the tag of the desired component inside the propertyFilter.
E.g:
<propertyFilter id="licenseFilter" property="license.name" operation="EQUAL" dataLoader="organizationsDl" visible="false">
<comboBox id="licenseCombo" allowCustomValue="false"/>
</propertyFilter>
In addition, the “MultiSelectComboBox” component is great for multiple selection of values. MultiSelectComboBox sample .
When the issue of implementing the “IN” operator will be solved, your code should be transformed as this:
<propertyFilter id="licenseFilter" property="license.name" operation="EQUAL" dataLoader="organizationsDl" visible="false">
<multiSelectComboBox id="licenseMultiCombo" allowCustomValue="false"/>
</propertyFilter>
I hope my answer will be helpful for you.
Regards,
Dmitriy