Set a dataCombo selection
Hi
How can I set a default value in a dataCombo?
I tried
ClientMethod onloadHandler() [ Language = javascript ]
{
zenPage.getComponentById('mycombo').setProperty('selectedIndex',0);
//zenSetProp('mycombo','selectedIndex',0);
}
and didn't work, I can not use the value property because I don't know what the values in my combo are going to because they loaded OnCreateResultSet, I'm only looking to make always the first value selected by default
Thanks
Comments
To set a default value in a dataCombo component, you can use the zenSetProp JavaScript function. Here’s a working example:
In your Zen ClientMethod, you can use the following code:
zenSetProp('mycombo', 'value', 'yourDefaultValue');Replace
'yourDefaultValue'with the actual value you want to set as the default.You can also set the
valuedirectly during the page creation:zenPage.getComponentById('mycombo').setProperty('value', 'yourDefaultValue');
Make sure:
- The
valueyou set matches one of thedataCombooptions. - If the
dataCombofetches data from a query, ensure the component is refreshed or the options are loaded before applying the default value [1].Sources: