Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Power BI
  3. Question
Power BI

Dynamic Lightning Select With Dynamic Amount of Options

Asked by Bhagwati Dubey Jul 1, 2021 1.8K views 1 answer
Share

About this question

I'm looking to have a dynamic input that can be either a Dynamic PickList OR A Dynamic Input such as text or DateTime. $A.createComponent(String type, Object attributes, function callback) I have been using the above to great effect with lightning input. However, when I try to do the same with lightning select, all of the guidance says that I can't have a dynamic amount of options as it seems each option has to be hardcoded like below!

$A.createComponent( "lightning:select", [ [ "aura:id": "input", "label": cmp.get("v.label"), "onchange": cmp.getReference("c.onChange") ], [ "option", { value: "Option 1", label: "Option 1" } ], [ "option", { value: "Option 2", label: "Option 2" } ] ], function(icmp, status, errorMessage) { if (status === "SUCCESS") { var body = cmp.get("v.body"); body.push(icmp); cmp.set("v.body", body); } else if (status === "INCOMPLETE") { console.log("No response from server or client is offline.") } else if (status === "ERROR") { console.log("Error: " + errorMessage); } } );

Now I know I can set the value/label of each dynamically, but I cannot seem to have a dynamic number of options matching the length of a list, for example.


Your answer

1 Answer

More Power BI discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Power BI Blogs

Guides, tips and career advice on Power BI from JanBask experts.