I have a form with a dropdown box which I need to change the selected item in it. This is a update form which values returned from an http service and I'm trying to set the selected item using the following code. But it is returning an error. Really appriciate If someone can tell me how I can set the selected item.
cmbSuppliers.selectedItem = event.result.component.batches.batch.supplierid.toString();
I also tried the following as well, but still getting the
cmbSuppliers.selectedItem.id = event.result.component.batches.batch.supplierid.toString();
the combo box arraylist contain id field and the supplier name.
I'm getting the following error.
TypeError: Error #1010: A term is undefined and has no properties.
Try to use the selectedIndex property of the combobox to set the selectedItem in combobox. It is always a good approach to use the selectedIndex property to set the selecteditem.
Try using the below code:
var strSupplierId:String = event.result.component.batches.batch.supplierid.toString();
var supplierID:String = String(ddlDP.getItemAt(intLoop).supplierid);
if(strSupplierId == supplierID)
cmbSuppliers.selectedIndex = intLoop;
In the above code ddlDP is the cmbSuppliers dataprovider(which is an arraycollection).
If this post answers your question or helps, please kindly mark it as such.