How to change the value of combo box?

How to change the value of combo box?

  

Iam fetching list of formats from a table and displaying it in UI as shown


Value for the combo box is getting displayed as Id of the table. I want the value to be the type of format.Attached the property of combo box. Help me in getting it resolved.


Hi Ajithkumar, 

Did you take the online courses? Combo boxes are explained there. Please make sure you have all the basics down, so you can be a successful OutSystems developer.

That said, the Source Attribute Property specifies what is displayed in the combo box. You should probably have the label attribute in there. Also, the variable should be a local variable, not an attribute from the query.

Hi,

For Variable you should could use a local variable FileFormatsId of type FileFormats Identifier.

The Id of the selected FileFormats record will be stored in it when you change selection in the combobox.

Asuming this is a static entity, you can then acces the type value of the selected record like:

GetFileFormats(FileFormatsId).FileFormats.Type


Kilian Hekhuis wrote:

Hi Ajithkumar, 

Did you take the online courses? Combo boxes are explained there. Please make sure you have all the basics down, so you can be a successful OutSystems developer.

That said, the Source Attribute Property specifies what is displayed in the combo box. You should probably have the label attribute in there. Also, the variable should be a local variable, not an attribute from the query.

Yes, Agree made some mistakes. Still my concern is how to change the option value of the combo box(marked in yellow)?

Properties set for combo box

Hello Ajithkumar,

I would like to ask directly if you did the online training, and if yes, how long ago.
This is important because if you did the online training, you should know how the combo box works and if you did and do not know, we need to understand if it is something in the material that is not well explained.

In a very simplified way, Combo Boxes are attached to a variable, defined in the property Variable.
When you select an item in the list, the ID (or the field defined in Source Identifier Attribute) value for this item is stored in the variable.

THe other way also works. When the server builds the bage, if there is a valid value in this variable, the combo box will show this item as the selected one.

So, the way to SET the combo box to show a specific item of the list, is to set the Id of this item in the attached variable. 

But for me, your question is not clear, so I don't know if this is the answer you "need".

Cheers.

Eduardo Jauch wrote:

Hello Ajithkumar,

I would like to ask directly if you did the online training, and if yes, how long ago.
This is important because if you did the online training, you should know how the combo box works and if you did and do not know, we need to understand if it is something in the material that is not well explained.

In a very simplified way, Combo Boxes are attached to a variable, defined in the property Variable.
When you select an item in the list, the ID (or the field defined in Source Identifier Attribute) value for this item is stored in the variable.

THe other way also works. When the server builds the bage, if there is a valid value in this variable, the combo box will show this item as the selected one.

So, the way to SET the combo box to show a specific item of the list, is to set the Id of this item in the attached variable. 

But for me, your question is not clear, so I don't know if this is the answer you "need".

Cheers.

Hi Eduardo Jauch,

  I have gone through the online course I am clear with it and I can understand what you are saying.  My concern is how to change the value of options in the combo box  which is getting assigned as ID of the record fetched from DB.

Eg: Now the value is like<option value="1">csv</option>

I have to change it to <option value="csv">csv</option>

Hope Iam right.

Anyways thank you for your help.




Hi Ajithkumar,

If your Entity has an Identifier, the Source Identifier Attribute Property is greyed out, and you cannot select a different one. I consider this a bug in the Platform, but it is what it is. Therefore, if you really must do what you said, create a Structure with the desired Attributes, create a List of that Structure as Local Variable, assign that Variable the output of an Aggregate fetching the values from the Static Entity, and use the Variable as Source Record List of the Combo Box. Then you can set the Source Identifier Attribute.

Kilian Hekhuis wrote:

Hi Ajithkumar,

If your Entity has an Identifier, the Source Identifier Attribute Property is greyed out, and you cannot select a different one. I consider this a bug in the Platform, but it is what it is. Therefore, if you really must do what you said, create a Structure with the desired Attributes, create a List of that Structure as Local Variable, assign that Variable the output of an Aggregate fetching the values from the Static Entity, and use the Variable as Source Record List of the Combo Box. Then you can set the Source Identifier Attribute.

Hi Kilian,

 Thank you. Iam clear now. You have told a suggestion like this(create a List of that Structure as Local Variable, assign that Variable the output of an Aggregate fetching the values from the Static Entity). Structure entity will be different datatype and static entity will be different data type. Hope Iam right.



Solution

Hi Ajithkumar and Kilian,

An "easier" way that do what Kilian is suggesting is to use an Aggregate output list as the source of the combo box, instead of the Entity. In the aggregate, create a new column with the value you want to show in the list and chose this column as the Source Attribute. Now you can select the Identifier from the fields available.

Cheers.

EDIT:
New field in the aggregate

Configuration:

Result:

Result:

Solution

That's true, I forgot about that obscure bug :). Thanks Eduardo!

I'll post an eSpace showing the various options in a second...

Thanks, Kilian :)

And I learned something new, because I didn't know that the option value was indeed the identifier attribute chosen. Thanks :)

Cheers!

And here it is.

Combo box 1: use Source Entity directly. Pro: no query needed; Con: always uses Identifier for Variable (if present), sorting undefined in case of no Order By Attribute specified;

Combo box 2: uses an Aggregate. Pro: control over sorting; Con: same as 1

Combo box 3: uses an Aggregate with an extra calculated Attribute. Pro: you can select an Identifier Attribute if you use the calculated Attribute as Source Attribute; Con: needs extra Attribute just for this;

Combi box 4: uses a structure copied from an Aggregate. Pro: you can select any Attribute you want as Identifier Attribute; Con: needs extra Structure and assignment.

Eduardo Jauch wrote:

Thanks, Kilian :)

And I learned something new, because I didn't know that the option value was indeed the identifier attribute chosen. Thanks :)

Cheers!


Hi Eduardo Jauch/Kilian Hekhuis,


Thank You. Really that's good learning for me today. Thanks a lot.

You're welcome Ajithkumar. Could you please set one of our answers to "Solution"? Thanks.