Use combo box to fill decimal attribute - Best Practice advice

Hello, 

I have a form on which one of the attributes of the aggregate is a decimal. On the form this generates a input widget of the type Text. However, I want to control the input (0.25 / 0.50 / 0.75 / 1/ 1.25) to a max of 8. That would suggest populating the form with a combo box which must be bound to the decimal attribute on form save. 

Any best practice advice on how to achieve this? 

Regards Bouke 

Solution

Hi Bouke,

You have a number of options: one is to set the Input Widget to type Number and use the Extended Properties to set the min, max and step values to limit the input. The second option is what you suggest. In that case, you need to create a Decimal List with these values and use your Decimal Attribute as the Combo Box's Variable.

Solution

Hi Bouke,

I'd suggest you use the Combo Box's Special List to define those values. You can set the Option and Value values to be the same for each entry on the Special List. You can check this online lesson for an explanation of how to use combo boxes (and their special list).

Hope this helps

@Jorge: The downside to that is that a Special List can only hold Text, so you can't assign it directly to a Decimal Attribute, necessitating an extra Attribute + conversion afterwards. That's why I didn't mention it.

Hi Bouke,

If you want to ensure compatibility and make your input uniform across browsers, use a dropdown with a list. Min, max and step are still iffy properties - I think they're ignored in any IE besides Edge, and browsers will interpret step in different ways.

How you feed that list is up to you but I'd advise creating a Decimal List yourself in a helper method: that way, should you need this sort of dropdown in other places, you can just reuse your helper method to feed it elsewhere.

Afonso Carvalho wrote:

Hi Bouke,

If you want to ensure compatibility and make your input uniform across browsers, use a dropdown with a list. Min, max and step are still iffy properties - I think they're ignored in any IE besides Edge, and browsers will interpret step in different ways.

How you feed that list is up to you but I'd advise creating a Decimal List yourself in a helper method: that way, should you need this sort of dropdown in other places, you can just reuse your helper method to feed it elsewhere.

Afonso, 

would you be so kind to show/ refer to a way to setup such a helper method. I'm still a newby, so I know what you mean, but not how to make it work. 

Regards Bouke 


Kilian Hekhuis wrote:

@Jorge: The downside to that is that a Special List can only hold Text, so you can't assign it directly to a Decimal Attribute, necessitating an extra Attribute + conversion afterwards. That's why I didn't mention it.

hello, 

as at the moment I miss the skills to make a decimal list work i have implemented this option where the value is a integer and i devide by 4 to get the decimal. 

Regards Bouke 


Hi

Here a sample  of what i think kilian was saying.

using special variable to make intervals or 0.25 until 8 means you had to have 32 slots, thats a lot of slots to fill manualy so i think it is better do do an append.  

Note that if you had less than 32 values, using a ListAppendAll, then clicking the + icon in front of "SourceList", it would be easier to manual add them (but with so many values, a simple loop would probably be better).

Kilian Hekhuis wrote:

Hi Bouke,

You have a number of options: one is to set the Input Widget to type Number and use the Extended Properties to set the min, max and step values to limit the input. The second option is what you suggest. In that case, you need to create a Decimal List with these values and use your Decimal Attribute as the Combo Box's Variable.

Kilian, 

i used both your suggestions (in different parts of my app). The extended properties work the easiest I think, and in Chrome they seem to be working quite well. 

Thanks for your support. 


Carlos Gonçalves wrote:

Hi

Here a sample  of what i think kilian was saying.

using special variable to make intervals or 0.25 until 8 means you had to have 32 slots, thats a lot of slots to fill manualy so i think it is better do do an append.  

Carlos, 

thanks for your example. I used it to create the solution as suggested by Kilian.

Regards Bouke 


Hi Bouke,

You're most welcome. Happy coding!