I am trying to replicate the below code in my lightning app component
var opts = [
{ "class": "optionClass", label: "Option1", value: "opt1", selected: "true" },
{ "class": "optionClass", label: "Option2", value: "opt2" },
{ "class": "optionClass", label: "Option3", value: "opt3" }
];
cmp.find("InputSelectDynamic").set("v.options", opts);
All works well except the selected is not being set to specified row item.
My Code. Where isSelected is passing "true" for one of the value.
opts.push({class : "optionClass", label : labelData, value : innerRootLevel3, selected : isSelected});
opts.join(",");
Best Answer
I had also problems like this, eventually I have created the component dynamically like that (with 2 methods of setting the selected value because sometimes one does not work and sometimes the other):
on my markup, the drop-down is:
On my javascript code I am filling the data like this:
I Hope you can use this to solve your problem