DropDown menu not ordered


I have one question related to the order of the items inside the DropDown menus. In my case, I created a vocabulary containing locations, and that vocabulary is ordered alphabetically:

However, when I put this vocabulary into an object, and I open the DropDown menu, the order is lost, and the items are placed randomly (at least I could not find any logical order) (I cannot upload two photos, but it is happening like that)

The question is: Is there any way to have all these items ordered in any way, like alphabetically? If the answer is yes, how can I do it? I could not find anything about this topic in the documentation.

Thank you very much in advance!

After a lot of trial and error we found one way of changing the display order of vocabulary terms using pybis. But I still have questions and remarks about the handling of vocabularies with pybis:

Iterating over voc.get_terms() or creating a list from it is broken (tested with pybis 1.35.4). It looks like Things.__getitem__() cannot handle this, because openbis.get_term() requires a second argument (vocabularyCode). The exception is:

TypeError: Openbis.get_term() missing 1 required positional argument: 'vocabularyCode'

.move_to_top() on a term does not what I expect from this function. When I first move termA to top, then termB, then termC, I expect the order: termC, termB, termA. But the ordinals of the terms do not change, the display order is still random. That’s why our sorting approaches using this method did not succeed.

I finally ended up with an approach that seems to work, but is a bit ugly. Did any of you have a better solution for defining the display order of a vocabulary in a dropdown (based on the the label in this case)?

def sortVocabularyByLabel(voc):
    terms = voc.get_terms()
    # create a list of the terms, this is ugly, but iterating over terms seems to be broken :-(
    term_codes = list(terms.df.code)
    term_l = [terms[c] for c in term_codes]
    # sort the list by label
    term_l.sort(key=lambda t: t.label)
    # move first term to top
    t = term_l[0]
    prev_term = t.code
    # iterate over all terms and move each after previous
    for t in term_l[1:]:
        prev_term= t.code

Thank you!

Dear Jörg,

If you have a problem using Pybis with the latest production version.

Please provide us with a code sniped without dependencies of the steps leading to the error.

We will review it and come back to you, we want for sure to fix those as they are found!

I recommend you use the helpdesk for this!

On the meantime I would try to use this method from the Openbis object:

    def get_terms(self, vocabulary=None, start_with=None, count=None, use_cache=True):
        """Returns information about existing vocabulary terms.
        If a vocabulary code is provided, it only returns the terms of that vocabulary.