Expand my Community achievements bar.

SOLVED

How to set default value to dropdown widget dnamically?

Avatar

Level 7

Hi,

I'm setting the "text" and "value" to dropdown(xtype:selection,type:select) widget using optionsProvider dynamically. I'm unable to set the default to this dropdown. Is it possible to set default value dynamically? Please let me know.

Thanks,

AryA.

1 Accepted Solution

Avatar

Correct answer by
Level 10

We have a community article that talks about dynamically setting custom xtype controls:

http://helpx.adobe.com/experience-manager/using/dynamically-updating-aem-custom-xtype.html

To get language - you will certainly have to use some JS app logic. 

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

We have a community article that talks about dynamically setting custom xtype controls:

http://helpx.adobe.com/experience-manager/using/dynamically-updating-aem-custom-xtype.html

To get language - you will certainly have to use some JS app logic. 

Avatar

Level 7

Hi Scott,

I'm able to get the language using JS API and also I'm able to see the respective values for dropdown in respective language. But I'm unable to set the default value to this dropdown dynamically. If I set "defaultValue" to some "None" for English on the dropdown widget, if we open the dropdown in French language preference, it is showing "None" instead of some French word, "Accun". Any idea?

Thanks,

AryA.

Avatar

Level 10

Once you determine the selected language -  call a user-defined method (defined in your custom xtype) that clears the drop down control and re-populate it with a data source that contains string values that are in a specific language. 

Avatar

Level 10

Hi Arya,

The way it works is when the default value matches one of the options value. So use the property 'defaultValue' on the node having xtype as 'selection'.

Thanks,
Sham

Avatar

Level 7

Hi Sham,

Actually I've to show the corresponding value in different languages. If I add "defaultValue" to node then in different language also it will show the same English default value. For example, I've to show "None" in English and "Accun" in French. If I set "defaultValue" to "None" then it will show "None" when we author in "French" language. Correct me if I'm wrong. Please let me know the solution. I think we can't achieve this using i18n as well. sad

Thanks,

AryA.