Last active
August 14, 2016 05:07
-
-
Save msrivastav13/05868d16a18cab3db1b730bb6abb535d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
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); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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