You need to sign in to do that
Don't have an account?
Niki Shah 12
how to display record in output text using lightning component
In this page table is working good but datais not display in outputtext
controller
({
doInit : function(component, event, helper) {
var action = component.get("c.getProjectDetails");
//action.setparm
action.setCallback(this,function(response){
if (response.getState() === "SUCCESS"){
component.set("{!v.contacts}",response.getReturnValue());
}
var dodge__DR_NBR__c = response.getState();
if (dodge__DR_NBR__c === "SUCCESS") {
component.set("v.contacts", response.getReturnValue());
console.log(response.getReturnValue());
}
}
);
var action1 = component.get("c.getProjectList");
action1.setCallback(this,function(response){
if (response.getState() === "SUCCESS"){
component.set("{!v.details}",response.getReturnValue());
}
var dodge__DR_NBR__c = response.getState();
if (dodge__DR_NBR__c === "SUCCESS") {
component.set("v.details", response.getReturnValue());
console.log(response.getReturnValue());
}
}
);
$A.enqueueAction(action);
$A.enqueueAction(action1);
}
})
component
<aura:component controller="LeadRep" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="contacts" type="String" />
<aura:attribute name="details" type="String" default="hello"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Use a data table from the Lightning Design System: https://www.lightningdesignsystem.com/components/data-tables/ -->
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-account" title="Rep_Lead">
<lightning:icon iconName="doctype:image" alternativeText="Doc image" />
<span class="slds-assistive-text">Rep Lead</span>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Rep_Lead">
<span>Rep Lead</span>
</a>
</h2>
</div>
</header>
</div>
<div class="slds-card__body slds-card__body_inner">Card Body</div>
</article>
<div class="slds-box slds-theme_default">
<h2>Contact Information</h2>
<div class="slds-grid slds-gutters">
<div class="slds-col">
<span><ui:inputText label="Dodge Report Number" value="{!v.contacts.dodge__DR_NBR__c}" /></span>
<span><span><ui:inputText label="Project name" value="{!v.contacts.dodge__TITLE__c}"/></span></span>
<span><span><ui:inputText label="Project name" value="{!detail.dodge__PROJECT_ROLE__c}"/></span></span>
</div>
</div>
</div>
<table class="slds-table slds-table_cell-buffer slds-table_bordered">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col">
<div class="slds-truncate" title="dodge__TITLE__c">dodge TITLE</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="dodge__PROJECT_ROLE__c">Project Role</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="dodge__DR_NBR__c">Dodge Report Number</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="dodge__P_ADDR_LINE1__c">Address1</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Project Opportunity">Project Opportunity</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.details}" var="detail">
<aura:iteration items="{!v.contacts}" var="contact">
apex class
public class LeadRep {
@AuraEnabled
Public static list<dodge__DODGE_PROJECT__c>getProjectDetails(){
return [SELECT dodge__TITLE__c,dodge__DR_NBR__c,dodge__P_ADDR_LINE1__c FROM dodge__DODGE_PROJECT__c where dodge__DR_NBR__c='201800529072'];
}
/* @AuraEnabled
Public static list<dodge__DODGE_ROLE__c>getProjectList() {
return [SELECT dodge__PROJECT_ROLE__c FROM dodge__DODGE_ROLE__c where dodge__DR_NBR__c='201800529072'];
}*/
@AuraEnabled
Public static list<dodge__DODGE_ROLE__c>getProjectList() {
return [SELECT dodge__PROJECT_ROLE__c,dodge__DODGE_ACCOUNT__c,dodge__DODGE_CONTACT__r.dodge__FIRM_NAME__c FROM dodge__DODGE_ROLE__c where dodge__DR_NBR__c='201800529072'];
}
/* @AuraEnabled
Public static list<dodge__Dodge_Project_Lead__c>getDodgeProjectLeadList() {
return [SELECT dodge__P_ADDR_LINE1__c FROM dodge__Dodge_Project_Lead__c where dodge__DR_NBR__c='201800529072'];
}*/
}
<tr class="slds-hint-parent">
<td>
<div class="slds-truncate" title="{!contact.dodge__TITLE__c}">{!contact.dodge__TITLE__c}</div>
</td>
<td>
<div class="slds-truncate" title="{!detail.dodge__PROJECT_ROLE__c}">{!detail.dodge__PROJECT_ROLE__c}</div>
</td>
<td>
<div class="slds-truncate" title="{!contact.dodge__DR_NBR__c}">{!contact.dodge__DR_NBR__c}</div>
</td>
<td>
<div class="slds-truncate" title="{!contact.dodge__P_ADDR_LINE1__c}">{!contact.dodge__P_ADDR_LINE1__c}</div>
</td>
<td>
<div class="slds-truncate" title="Create"><a href="swifterfans--lf1.lightning.force.com/lightning/o/Opportunity/list?filterName=Recent">Create</a></div>
</td>
</tr>
</aura:iteration>
</aura:iteration>
</tbody>
</table>
</aura:component>
controller
({
doInit : function(component, event, helper) {
var action = component.get("c.getProjectDetails");
//action.setparm
action.setCallback(this,function(response){
if (response.getState() === "SUCCESS"){
component.set("{!v.contacts}",response.getReturnValue());
}
var dodge__DR_NBR__c = response.getState();
if (dodge__DR_NBR__c === "SUCCESS") {
component.set("v.contacts", response.getReturnValue());
console.log(response.getReturnValue());
}
}
);
var action1 = component.get("c.getProjectList");
action1.setCallback(this,function(response){
if (response.getState() === "SUCCESS"){
component.set("{!v.details}",response.getReturnValue());
}
var dodge__DR_NBR__c = response.getState();
if (dodge__DR_NBR__c === "SUCCESS") {
component.set("v.details", response.getReturnValue());
console.log(response.getReturnValue());
}
}
);
$A.enqueueAction(action);
$A.enqueueAction(action1);
}
})
component
<aura:component controller="LeadRep" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="contacts" type="String" />
<aura:attribute name="details" type="String" default="hello"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Use a data table from the Lightning Design System: https://www.lightningdesignsystem.com/components/data-tables/ -->
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-account" title="Rep_Lead">
<lightning:icon iconName="doctype:image" alternativeText="Doc image" />
<span class="slds-assistive-text">Rep Lead</span>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Rep_Lead">
<span>Rep Lead</span>
</a>
</h2>
</div>
</header>
</div>
<div class="slds-card__body slds-card__body_inner">Card Body</div>
</article>
<div class="slds-box slds-theme_default">
<h2>Contact Information</h2>
<div class="slds-grid slds-gutters">
<div class="slds-col">
<span><ui:inputText label="Dodge Report Number" value="{!v.contacts.dodge__DR_NBR__c}" /></span>
<span><span><ui:inputText label="Project name" value="{!v.contacts.dodge__TITLE__c}"/></span></span>
<span><span><ui:inputText label="Project name" value="{!detail.dodge__PROJECT_ROLE__c}"/></span></span>
</div>
</div>
</div>
<table class="slds-table slds-table_cell-buffer slds-table_bordered">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col">
<div class="slds-truncate" title="dodge__TITLE__c">dodge TITLE</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="dodge__PROJECT_ROLE__c">Project Role</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="dodge__DR_NBR__c">Dodge Report Number</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="dodge__P_ADDR_LINE1__c">Address1</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Project Opportunity">Project Opportunity</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.details}" var="detail">
<aura:iteration items="{!v.contacts}" var="contact">
apex class
public class LeadRep {
@AuraEnabled
Public static list<dodge__DODGE_PROJECT__c>getProjectDetails(){
return [SELECT dodge__TITLE__c,dodge__DR_NBR__c,dodge__P_ADDR_LINE1__c FROM dodge__DODGE_PROJECT__c where dodge__DR_NBR__c='201800529072'];
}
/* @AuraEnabled
Public static list<dodge__DODGE_ROLE__c>getProjectList() {
return [SELECT dodge__PROJECT_ROLE__c FROM dodge__DODGE_ROLE__c where dodge__DR_NBR__c='201800529072'];
}*/
@AuraEnabled
Public static list<dodge__DODGE_ROLE__c>getProjectList() {
return [SELECT dodge__PROJECT_ROLE__c,dodge__DODGE_ACCOUNT__c,dodge__DODGE_CONTACT__r.dodge__FIRM_NAME__c FROM dodge__DODGE_ROLE__c where dodge__DR_NBR__c='201800529072'];
}
/* @AuraEnabled
Public static list<dodge__Dodge_Project_Lead__c>getDodgeProjectLeadList() {
return [SELECT dodge__P_ADDR_LINE1__c FROM dodge__Dodge_Project_Lead__c where dodge__DR_NBR__c='201800529072'];
}*/
}
<tr class="slds-hint-parent">
<td>
<div class="slds-truncate" title="{!contact.dodge__TITLE__c}">{!contact.dodge__TITLE__c}</div>
</td>
<td>
<div class="slds-truncate" title="{!detail.dodge__PROJECT_ROLE__c}">{!detail.dodge__PROJECT_ROLE__c}</div>
</td>
<td>
<div class="slds-truncate" title="{!contact.dodge__DR_NBR__c}">{!contact.dodge__DR_NBR__c}</div>
</td>
<td>
<div class="slds-truncate" title="{!contact.dodge__P_ADDR_LINE1__c}">{!contact.dodge__P_ADDR_LINE1__c}</div>
</td>
<td>
<div class="slds-truncate" title="Create"><a href="swifterfans--lf1.lightning.force.com/lightning/o/Opportunity/list?filterName=Recent">Create</a></div>
</td>
</tr>
</aura:iteration>
</aura:iteration>
</tbody>
</table>
</aura:component>
I have gone through your code and everything seems to work fine except the component. As per my knowledge using two NESTED aura:iterations is creating problems. You should try using two different aura:iterations along with their fields. As using nested aura:iteration, the inner iteration will run till its length and every table element will not be used properly. Ex: !detail.dodge__PROJECT_ROLE__c will run multiple times as per length of v.contacts updating the same value. Hence I recommend you to correct this logic.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi