You need to sign in to do that
Don't have an account?

how to display the list of opportunities using lightning component .. help me where am I going wrong
Here is my code, I was not able to find the error ..
====================================
component :
<aura:component controller = "opplist">
<aura:attribute name="opportunities" type="list"/>
<aura:handler name="init" value="doinit" action="{!v.doinit}"/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
<thead>
<tr class="slds-text-heading--label">
<th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
<th scope="col"><div class="slds-truncate" title="Name">AccountId</div></th>
<th scope="col"><div class="slds-truncate" title="Type">probability</div></th>
<th scope="col"><div class="slds-truncate" title="Number Of Employees">stageName</div></th>
<th scope="col"><div class="slds-truncate" title="Ticker Symbol">Close Date</div></th>
<th scope="col"><div class="slds-truncate" title="Phone">Opportunity Currency</div></th>
<th scope="col"><div class="slds-truncate" title="Delete">Amount</div></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.opportunities}" var ="x">
<tr>
<th scope="row"><div class="slds-truncate" title="{!account.Id}">{!x.Id}</div></th>
<td><div class="slds-truncate" title="{!account.Name}">{!x.AccountId}</div></td>
<td><div class="slds-truncate" title="{!account.Type}">{!x.probability}</div></td>
<td><div class="slds-truncate" title="{!account.NumberOfEmployees}">{!x.stageName}</div></td>
<td><div class="slds-truncate" title="{!account.NumberOfEmployees}">{!x.closeDate}</div></td>
<td><div class="slds-truncate" title="{!account.TickerSymbol}">{!x.OpportunityCurrency}</div></td>
<td><div class="slds-truncate" title="{!account.Phone}">{!x.Amount}</div></td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:component>
===============================================
controller :
public class opplist {
@AuraEnabled
public static list<opportunity> getopplist(){
list<opportunity> opps = new list<opportunity>([select Id,AccountId,probability,stageName from opportunity]);
return opps;
}
}
===========================
Helper controller :
({
getopplist : function(component) {
var action = component.get("v.getopplist");
var self = this;
action.setCallback(this, function(actionResult) {
component.set('v.getopplist', actionResult.getReturnValue());
});
$A.enqueueAction(action);
}
})
================================================
component controller
({
doinit : function(component, event, helper) {
helper.getAccountlist(component);
}
})
====================================
component :
<aura:component controller = "opplist">
<aura:attribute name="opportunities" type="list"/>
<aura:handler name="init" value="doinit" action="{!v.doinit}"/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
<thead>
<tr class="slds-text-heading--label">
<th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
<th scope="col"><div class="slds-truncate" title="Name">AccountId</div></th>
<th scope="col"><div class="slds-truncate" title="Type">probability</div></th>
<th scope="col"><div class="slds-truncate" title="Number Of Employees">stageName</div></th>
<th scope="col"><div class="slds-truncate" title="Ticker Symbol">Close Date</div></th>
<th scope="col"><div class="slds-truncate" title="Phone">Opportunity Currency</div></th>
<th scope="col"><div class="slds-truncate" title="Delete">Amount</div></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.opportunities}" var ="x">
<tr>
<th scope="row"><div class="slds-truncate" title="{!account.Id}">{!x.Id}</div></th>
<td><div class="slds-truncate" title="{!account.Name}">{!x.AccountId}</div></td>
<td><div class="slds-truncate" title="{!account.Type}">{!x.probability}</div></td>
<td><div class="slds-truncate" title="{!account.NumberOfEmployees}">{!x.stageName}</div></td>
<td><div class="slds-truncate" title="{!account.NumberOfEmployees}">{!x.closeDate}</div></td>
<td><div class="slds-truncate" title="{!account.TickerSymbol}">{!x.OpportunityCurrency}</div></td>
<td><div class="slds-truncate" title="{!account.Phone}">{!x.Amount}</div></td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:component>
===============================================
controller :
public class opplist {
@AuraEnabled
public static list<opportunity> getopplist(){
list<opportunity> opps = new list<opportunity>([select Id,AccountId,probability,stageName from opportunity]);
return opps;
}
}
===========================
Helper controller :
({
getopplist : function(component) {
var action = component.get("v.getopplist");
var self = this;
action.setCallback(this, function(actionResult) {
component.set('v.getopplist', actionResult.getReturnValue());
});
$A.enqueueAction(action);
}
})
================================================
component controller
({
doinit : function(component, event, helper) {
helper.getAccountlist(component);
}
})
Please try below code.
Hope this helps,
Regards,
Ashish Kr.
please try the soltion given below :-
Component:-
..................................................................
<aura:component controller = "opplist">
<aura:attribute name="opportunities" type="list"/>
<aura:handler name="init" value="{!this}" action="{!c.doinit}"/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
<thead>
<tr class="slds-text-heading--label">
<th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
<th scope="col"><div class="slds-truncate" title="Name">AccountId</div></th>
<th scope="col"><div class="slds-truncate" title="Type">probability</div></th>
<th scope="col"><div class="slds-truncate" title="Number Of Employees">stageName</div></th>
<th scope="col"><div class="slds-truncate" title="Ticker Symbol">Close Date</div></th>
<th scope="col"><div class="slds-truncate" title="Phone">Opportunity Currency</div></th>
<th scope="col"><div class="slds-truncate" title="Delete">Amount</div></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.opportunities}" var ="x">
<tr>
<th scope="row"><div class="slds-truncate" title="{!x.Id}">{!x.Id}</div></th>
<td><div class="slds-truncate" title="{!x.AccountId}">{!x.AccountId}</div></td>
<td><div class="slds-truncate" title="{!x.Type}">{!x.Probability}</div></td>
<td><div class="slds-truncate" title="{!x.NumberOfEmployees}">{!x.StageName}</div></td>
<td><div class="slds-truncate" title="{!x.NumberOfEmployees}">{!x.CloseDate}</div></td>
<td><div class="slds-truncate" title="{!x.TickerSymbol}">{!x.OpportunityCurrency}</div></td>
<td><div class="slds-truncate" title="{!x.Phone}">{!x.Amount}</div></td>
</tr>
</aura:iteration>
</tbody>
</table>
</aura:component>
...................................................................................
Controller:-
...................................................................................
({
doinit : function(component, event, helper) {
helper.getAccountlist(component);
}
})
....................................................................................
Controller Helper:-
....................................................................................
({
getAccountlist : function(component) {
var action = component.get("c.getopplist");
var self = this;
action.setCallback(this, function(actionResult) {
component.set('v.opportunities', actionResult.getReturnValue());
});
$A.enqueueAction(action);
}
})
...................................................................................
Server side controller:-
...................................................................................
public class opplist {
@AuraEnabled
public static list<opportunity> getopplist(){
list<opportunity> opps = new list<opportunity>([select Id,AccountId,probability,stageName from opportunity]);
return opps;
}
}
Thanks,
Happy Coding :)