I hope I’m not boring anyone, sitting here talking to myself about checkboxes. ;^}
But Robert’s question started me off on a chain of investigation/thinking/learning about checkboxes in a Servoy/SQL environment. Here are two more tidbits
Robert had asked:
A minor display problem for me to solve is eliminating the spaces between the characters (H M A should be AHM)
You must have the field on the right formatted with text display. Choices made in a checkbox field are entered into the data field (in what seems like arbitrary order) separated by line-return characters … i.e., a return-delimited list is what results. If you change the field on the right to Text Area display you’ll see what I mean.
if displayed in a text field (see Attributes text field on the right on the picture) and how to sort order that field alphabetically
You could probably handle the return-delimited list as an array and use a method attached to the checkbox field that uses a string function to sort the values… (I don’t know, just guessing) … HOWEVER, your desire to see the values sorted only points us back to your original observation that checkbox fields break the first normal form. If you want to work with, manipulate, report on or do much more than just look at the selections, use a fully relational approach instead.
For example, if you normalized the structure and stored each checkbox choice in its own row in a table you could then …
… create a list form in this valueChoices table and attach an onShow method that loads all records & then sorts them
… make the choiceDescription field on this form non-editable and attach a method that creates a related record if none exists for that choice, and that deletes a related record if it does exist (i.e., your method would act as a “toggle” to “turn the selection on and off”)
… define some kind of unstored calc to apply highlighting or even a checked box graphic to the rows on the list form, depending on each row’s “selected” or “non-selected” status
… put the valueChoices list form into an unrelated tab panel on the form the user will be working in
[[now I bet David W is about to post something that makes this approach look way overdone! (in fact, I hope he does)]]
No matter how much extra work this might look like up front compared to simply formatting a checkox field to display a value list, by sticking with normalized data you will make your life (and your users’ lives) SOOOO much easier down the road.
For example, check a couple of boxes in your checkbox field, go into Find mode, and try finding all records that have one of the choices checked. Only records that have ONLY that choice will show up, when the user would expect that ANY record that has that choice checked (plus perhaps others checked as well) would be returned. Using your screenshot as an example, if you entered Find mode and checked the “A Airport” box, you would expect that record to turn up, but it won’t. (See Finds on Checkboxes - How get Servoy to act like FMP? - Classic Servoy - Servoy Community) So to allow users to perform finds on checkbox fields, you will be writing & maintaining a rather complex onSearch method…
Or try generating a report that summarizes a count of each value-list choice. A snap with a related table that stores each selected value in a row; and significantly more complex to build the same report with return-delimited checkbox choices.
I’ve made a little start on a suggested UI for providing a checkbox-like UI within a normalized structure. If I get anywhere with it, I’ll post it as my first Servoy demo!
kazar