You need to sign in to do that
Don't have an account?
Swamy P
Not able to show Accounts in Lightning page
Hello Team,
I have a functionality to show the accounts based on the search result, here is my code.
APP:
<aura:application >
<c:SearchBarCmp />
<c:AccountListCmp />
</aura:application>
AccountList Component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="Swamy_2011.AccountsWithContactsSearchController">
<aura:attribute name="accnts" type="Account[]"/>
<aura:handler event="Swamy_2011:SearchKeyChange" action="{!c.SearchKeyChange}"/>
<aura:iteration items="{!v.accnts}" var="acc">
<p>{!acc.Name}</p>
</aura:iteration>
</aura:component>
AccListCmpJS:
({
SearchKeyChange : function(component, event, helper) {
var searchKey = event.getParam("searchKey");
var action = component.get("c.accByIds");
action.setParams({
"searchKey": searchKey
});
action.setCallback(this, function(a) {
component.set("v.accnts", a.getReturnValue());
});
$A.enqueueAction(action);
}
})
Class:
public class AccountsWithContactsSearchController {
@AuraEnabled
Public static List<Account> accByIds(string accId){
List<Account> acc = new List<Account>();
String name = string.escapesinglequotes(accId) + '%';
acc = [Select Id, Name, Type from Account where Name Like:name];
return acc;
}
}
Same logic working for Contact records, Suggest me where i missed the code for Account, i hope everything perfect otherthan CSS.
Thanks,
Swamy P R N.
I have a functionality to show the accounts based on the search result, here is my code.
APP:
<aura:application >
<c:SearchBarCmp />
<c:AccountListCmp />
</aura:application>
AccountList Component:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="Swamy_2011.AccountsWithContactsSearchController">
<aura:attribute name="accnts" type="Account[]"/>
<aura:handler event="Swamy_2011:SearchKeyChange" action="{!c.SearchKeyChange}"/>
<aura:iteration items="{!v.accnts}" var="acc">
<p>{!acc.Name}</p>
</aura:iteration>
</aura:component>
AccListCmpJS:
({
SearchKeyChange : function(component, event, helper) {
var searchKey = event.getParam("searchKey");
var action = component.get("c.accByIds");
action.setParams({
"searchKey": searchKey
});
action.setCallback(this, function(a) {
component.set("v.accnts", a.getReturnValue());
});
$A.enqueueAction(action);
}
})
Class:
public class AccountsWithContactsSearchController {
@AuraEnabled
Public static List<Account> accByIds(string accId){
List<Account> acc = new List<Account>();
String name = string.escapesinglequotes(accId) + '%';
acc = [Select Id, Name, Type from Account where Name Like:name];
return acc;
}
}
Same logic working for Contact records, Suggest me where i missed the code for Account, i hope everything perfect otherthan CSS.
Thanks,
Swamy P R N.
Below is a code for the same . Hope it will help you.
Aura Component Code :
Aura App Code : Aura Controller Code :
Aura Helper Code :
Apex Class Code :
SCREENSHOT :
Regards,
Akshay