setting default value for dropdown

Hi,

   I am using optiondatasource to populate a dropdown.The first value that comes in the datasource should be set as the default value in the dropdown.Please let me know how to set default value in this case.

Thanks,
Keerthi

setting default value for dropdown

Hi,
Even I am facing the same problem.

Any updates on this?

Thanks
Vini

Hi guys,

You can do this by adding a dataArrived() handler to the SelectItem:

dataArrived: function (startRow, endRow, data) {
    if (data && data.length > 0)
    {
        this.setValue(data[0][this.getValueFieldName()]);
    }
}

setting default value for dropdown

Hi,
I am having a field of type “Select” in which I am getting the values using a datasource, sampleDS.

Now, if I have to write the dataArrived() for this select filed,
what are the parameters to be passed to this function.

Can you please clarify what is the “data” that you had mentioned in the earlier reply?

Thanks,
Vini.

Hi Vini,

Just take a look at the docs for dataArrived to find the parameters (the docs are searchable). The pickList is performing a “fetch” DSRequest against the optionDataSource to retrieve data - dataArrived() is passing the information that the fetch operation returns.

Hi,
I also tried the above metioned solution. I am unable to get the first value in the result set. The dataArrived is having a parameter ‘data’,which points to the result set. But, I am unable to get the first value of it.Please help me out in this.

Thanks,
Sravanthi

Sorry, rather than data[0], that should be data.get(0), so:

dataArrived: function (startRow, endRow, data) {
    if (data && data.length > 0)
    {
        this.setValue(data.get(0)[this.getValueFieldName()]);
    }
}