Question
· Oct 14

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

Product version: IRIS 2024.3
Discussion (1)2
Log in or sign up to continue

To set a default value in a dataCombo component, you can use the zenSetProp JavaScript function. Here’s a working example:

  1. 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.

  2. You can also set the value directly during the page creation:

    zenPage.getComponentById('mycombo').setProperty('value', 'yourDefaultValue');
    

Make sure:
- The value you set matches one of the dataCombo options.
- If the dataCombo fetches data from a query, ensure the component is refreshed or the options are loaded before applying the default value [1].

Sources: