Sort Order of Drop Downs in Filter Control

We have noticed the sort order of the values in the search conditions that appear as drop downs in the filter control don’t seem to be consistent. Is there a way to control the ordering of the available values in these drop downs?

Thank you,
Corey Amoruso

There is no way do declare a sort order for dropdown lists of entities in generic filter.
Maybe one of the following options may be useful for you:

  1. Use the pickerField instead of the dropdown list. You can define that a pickerField should be used by the @Lookup annotation on the attribute in the entity class.
  2. You can always add a set of UI components to the screen. These components may be used for filtering a table instead of generic filter. See the example in the DataLoadCoordinator documentation.

Thank you for the options you gave, we will look into using one of these.

Hi @Corey.Amoruso and @gorbunkov,
Sorry for “resurrecting” this topic, but I had the same need reported by @Corey.Amoruso and I came up with a solution that may be useful to others as well.

What I have implemented is not exactly be able to define an order for the generic filters dropdown, but instead sort entities by the InstanceName by default. For our need, this solution fitted perfectly. The following steps where needed to implement this behavior:

  1. Extend the class DataManagerClientImpl
    ExtDataManagerClientImpl.java (3.0 KB)

  2. Override default cuba_DataManager bean in web-spring.xml file:

<bean id="cuba_DataManager" class="com.example.web.client.ExtDataManagerClientImpl" />

After these changes, whenever a dropdown is shown in the generic filter for an Entity implementing InstanceName, it will be sorted in a consistent way. I don’t know if there is any additional side effects not correctly handled in this extension, but I’ve had no problem so far.

P.S.: The second part of the implementation commented in the class (sort by a parameter implementing Instance name) may not be required. I needed to implement it because we developed a custom translation component that has an Entity that is not being sort at database level.

Hope it helps anyone.

Regards.

1 Like

Hi Peterson,
I applied your solution in my project and it works like a charm!
Thank you very much for sharing it!
Regards,
Paolo

Hi,

Is there a CUBA-native solution for this issue ? We think it should be implemented as an option to the filter.

Thanks !!

Hi @peterson.br

Would you be able to re-share your solution for the ExtDataManagerClientImpl.java as we have the same requirements and would be really interested to see how you did it. Unfortunately the link to the code is no longer working.

Thanks
David