Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Last active August 14, 2016 05:07
Show Gist options
  • Save msrivastav13/05868d16a18cab3db1b730bb6abb535d to your computer and use it in GitHub Desktop.
Save msrivastav13/05868d16a18cab3db1b730bb6abb535d to your computer and use it in GitHub Desktop.
public with sharing class AccountTest{
@AuraEnabled
public static list<AccountWrapper> getlstacc(){
list<AccountWrapper> lstWrapper = new list<AccountWrapper>();
for(Account acc :[Select Id , Name , NumberofLocations__c from Account order by NumberofLocations__c limit 10]){
AccountWrapper accWrap = new AccountWrapper();
accWrap.Name = acc.Name;
accWrap.noOfLocations = integer.valueof(acc.NumberofLocations__c);
lstWrapper.add(accWrap);
}
return lstWrapper;
}
}
<aura:component controller="AccountTest" access="global">
<aura:handler name="init" action="{!c.fetchAccounts}" value="{!this}" />
<aura:attribute name="accounts" type="AccountWrapper[]" />
<ul>
<aura:iteration items="{!v.accounts}" var="account">
<li > <h3>{!account.name}</h3> </li>
<li > <h3>{!account.noOfLocations}</h3> </li>
</aura:iteration>
</ul>
</aura:component>
({
fetchAccounts : function(component, event, helper) {
var action = component.get("c.getlstacc ");
action.setCallback(this, function(data) {
component.set("v.accounts", data.getReturnValue());
});
$A.enqueueAction(action);
}
})
public class AccountWrapper {
@AuraEnabled
public string name;
@AuraEnabled
public integer noOfLocations ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment