Solved

Sorting on Checkbox(bit) works differently than I expect

  • 6 August 2019
  • 3 replies
  • 79 views

Userlevel 6
Badge +11
I have a list that I would like to sort on a Checkbox column (Datatype = Bit). If I Sort on this Checkbox column by selecting Sort in the Software Factory and give it the Sort order: Ascending, I would expect it to work like that the value 0 comes before the value 1.

But what I noticed is that it works the other way round; Ascending works like the checked rows come before the unchecked rows and Descending works like the unchecked rows come before the checked rows.

Has this been a conscious decision or does this indeed work the wrong way?

icon

Best answer by Vincent Doppenberg 8 August 2019, 10:01

Hi Mark,

Domains with checkbox controls are often configured to have elements, much like domains with combo controls. When sorting a column that has a domain with elements, the GUI will sort the column by the display value that corresponds with the database value (in your case, "Ja" comes before "Nee"). If you open the debug window in the Windows GUI, you will probably see a case statement in the order by clause that explains the order of the results.

Since this means that the result of a sort action depends on the language of the user, there have been wishes to change this behaviour to using the order_no of the element, rather than its display value. This is actually what Indicium does right now. However, we probably want to be able to support both ways, because you'd definitely want a list of countries for instance to be ordered alphabetically by their display value, it's very situational.

I hope that explains the behaviour. We're working on giving developers more control over it.
View original

3 replies

Userlevel 5
Badge +3
Indeed SQL does order it the expected way...
Userlevel 4
Badge +2
Hi Mark,

Domains with checkbox controls are often configured to have elements, much like domains with combo controls. When sorting a column that has a domain with elements, the GUI will sort the column by the display value that corresponds with the database value (in your case, "Ja" comes before "Nee"). If you open the debug window in the Windows GUI, you will probably see a case statement in the order by clause that explains the order of the results.

Since this means that the result of a sort action depends on the language of the user, there have been wishes to change this behaviour to using the order_no of the element, rather than its display value. This is actually what Indicium does right now. However, we probably want to be able to support both ways, because you'd definitely want a list of countries for instance to be ordered alphabetically by their display value, it's very situational.

I hope that explains the behaviour. We're working on giving developers more control over it.
Userlevel 6
Badge +11
Hi Mark,

Domains with checkbox controls are often configured to have elements, much like domains with combo controls. When sorting a column that has a domain with elements, the GUI will sort the column by the display value that corresponds with the database value (in your case, "Ja" comes before "Nee"). If you open the debug window in the Windows GUI, you will probably see a case statement in the order by clause that explains the order of the results.

Since this means that the result of a sort action depends on the language of the user, there have been wishes to change this behaviour to using the order_no of the element, rather than its display value. This is actually what Indicium does right now. However, we probably want to be able to support both ways, because you'd definitely want a list of countries for instance to be ordered alphabetically by their display value, it's very situational.

I hope that explains the behaviour. We're working on giving developers more control over it.


Hey Vincent,

Thanks for the answer. I understand that sorting on elements is practical in most situations.

But, this sorting looks very odd...



The English application sorts differently from the Dutch application. This is not something I can put in an application this way.

Where could I say that it should order on the bit value instead of the translation (which is hidden for the user)?

Edit: "We're working on giving developers more control over it." , Sorry, probably you are already working on this 😉 can't wait to use it in projects

I also noticed that we have elements for a checkbox domain, which is obsolete. I think if I remove that it'll sort on the values which is what I intend to have.

Reply