MultiSelectComboBox into propertyFilter

Greetings, I need to incorporate a multiselectcombobox into a propertyfilter. I’ve been looking at the information from the forums regarding this matter but I am unable to do it. If I associate it with a datacontainer, nothing appears, and if I associate it with an itemscontainer, it gives an error saying that the field must be of association type. Can you help me? If you need more information about this specific case, do not hesitate to contact me. Thank you. Best regards.

image
image

1 Like

Hi Jmix team,

We are having a similar problem in our project, we want to filter with multiselection. To be more specific, the customer should be able to filter a datagrid by selecting multiple regions, we tried different options but none of them really worked so far. Is the only option a customer filtering?

Thank you.

Not sure if this will work in jmix 2.0. But as I can see. PropertyFilter use PropertyFilterComponentGenerationStrategy to generate its components.

So u can override its method createEntityField(ComponentGenerationContext context) (or createEntityField(ComponentGenerationContext context, MetaPropertyPath mpp) in jmix 1.5) to create field. In our application we used it like that (jmix 1.5):

@Primary
@org.springframework.stereotype.Component
class OurPropertyFilterComponentGenerationStrategy(...) : PropertyFilterComponentGenerationStrategy(..) {

override fun createEntityField(context: ComponentGenerationContext, mpp: MetaPropertyPath): Component {
        if (mpp.range.isClass) {
            val metaClass = mpp.range.asClass()
            if (metaClass == metadata.getClass(FirstEntity::class.java)) {
                return createSuggestionPickerFieldForFirstEntity(mpp)
            }
            if (metaClass == metadata.getClass(SecondEntity::class.java)) {
                return createSuggestionPickerFieldForSecondEntity()
            }
        }

        return super.createEntityField(context, mpp)
    }

}