How to set default value to dropdown widget dnamically? | Community
Skip to main content
Dinu_Arya
Level 6
October 16, 2015
Solved

How to set default value to dropdown widget dnamically?

  • October 16, 2015
  • 5 replies
  • 1823 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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. 

5 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

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. 

Dinu_Arya
Dinu_AryaAuthor
Level 6
October 16, 2015

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.

smacdonald2008
Level 10
October 16, 2015

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. 

Sham_HC
Level 10
October 16, 2015

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

Dinu_Arya
Dinu_AryaAuthor
Level 6
October 16, 2015

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.