Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
---------------------------------------------- Apex controller ---------------------------------------------- public class Show_All_Accounts_Controller {
@AuraEnabled public static List<Account> getAllAccounts() { List<account> acc_list =[select Id,Name from account limit 100]; return acc_list; } }
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Apex:
Component:
Controller:
Application:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
In your code you can show only contacts record but i want to show Account with contacts record.
Please try below code:
Apex:
Component:
Controller:
Application:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Greetings to you!
I have gone through your query please try below code:
Show_All_Accounts Lightning component
---------------------------------------------
<aura:component controller="Show_All_Accounts_Controller">
<aura:attribute name="acclist" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.allAccount}"/>
<table aria-multiselectable="true" class="slds-table slds-table_bordered slds-table_fixed-layout slds-table_resizable-cols" role="grid">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col">
<div class="slds-truncate" title="Account Id">ACCOUNT ID</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Account Name">ACCOUNT NAME</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.acclist}" var="acc">
<tr>
<td>
{!acc.Id}
</td>
<td>
{!acc.Name}
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:component>
----------------------------------------------
Javascript controller
----------------------------------------------
({
allAccount : function(component, event, helper) {
var action = component.get("c.getAllAccounts");
action.setCallback(this,function(a)
{
component.set("v.acclist",a.getReturnValue()) ;
});
$A.enqueueAction(action);
}
})
----------------------------------------------
Apex controller
----------------------------------------------
public class Show_All_Accounts_Controller {
@AuraEnabled
public static List<Account> getAllAccounts()
{
List<account> acc_list =[select Id,Name from account limit 100];
return acc_list;
}
}
-------------------------
Lightning application
-------------------------
<aura:application extends="force:slds">
<c:Show_All_Accounts />
</aura:application>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com