单击输入字段时显示项目记录



我是aura组件的新手。我有一个要显示项目记录的字段。单击该字段我应该会得到项目记录所需的输出点击输入字段,我应该得到这样的记录有人能帮我吗

**Component :** 

<aura:component >
<div class="slds-align_absolute-center">
<lightning:layoutItem size="4">
<table> <tr><td style="padding:20px;">
<lightning:input type="sObject" aura:id="test" name="Project" label="Project" value="" placeholder="search project" onClick="{!c.handleClick}"/>
</td></tr>
</table>
</lightning:layoutItem>
</div> 
</aura:component>

**Controller :**
public class ListOfProjects {
@AuraEnabled
public  static List<project__c> getProjectList() {
List<project__c> myProjects = [SELECT Name from project__c ];
return myProjects;
}
}

**.Js file :** 
({
handleClick : function(component, event, helper) {
var action = component.get("c.getProjectList");
action.setCallback(this, function(response) {
console.log(response.getReturnValue());
component.set("v.Projects" ,response.getReturnValue());
});
$A.enqueueAction(action);
}
})

[Required output][1]

[1]: https://i.stack.imgur.com/DQhXw.jpg

您可以使用闪电:combobox

https://developer.salesforce.com/docs/component-library/bundle/lightning:combobox/example

最新更新