【发布时间】:2021-06-21 12:35:28
【问题描述】:
我是光环组件的新手。我有要显示项目记录的字段。On click of field I should get project records 期望输出On click of input field , I should get records like this 谁能帮帮我
**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
【问题讨论】:
标签: salesforce apex apex-code salesforce-lightning