You need to sign in to do that
Don't have an account?
DJ 367
Lightning example is not working
Hello All,
I have made two lightning component my example is when I select Account Rating it should display related Account record, I am not sure where I am doing mistake , can someone please help me.
My code is below:
Component: 2
App:
Thanks.
I have made two lightning component my example is when I select Account Rating it should display related Account record, I am not sure where I am doing mistake , can someone please help me.
My code is below:
// class public with sharing class AccountRating { @AuraEnabled public static List<Account> AccMethod(RatParam){ return [select Id,name,site,Rating from Account where Rating = : RatParam]; } }Lightning Component:
<aura:component > <aura:attribute name ="Acc" type="Account" /> <div class="demo-only" style="width: 30rem;"> <article class="slds-tile"> <h3 class="slds-tile__title slds-truncate" title="Account Name"><a href="javascript:void(0);">{!v.Acc.Name}</a></h3> <div class="slds-tile__detail"> <dl class="slds-list_horizontal slds-wrap"> <dt class="slds-item_label slds-text-color_weak slds-truncate" title="First Label">Rating:</dt> <dd class="slds-item_detail slds-truncate" title="Description for first label">{!v.Acc.Rating}</dd> <dt class="slds-item_label slds-text-color_weak slds-truncate" title="Second Label">Site:</dt> <dd class="slds-item_detail slds-truncate" title="Description for second label">{!v.Acc.Site}</dd> </dl> </div> </article> </div> </aura:component>
Component: 2
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > <aura:attribute Name = "Rating" type = "List" /> <div class="slds-form-element"> <label class="slds-form-element__label" for="select-01">Select Label</label> <div class="slds-form-element__control"> <div class="slds-select_container"> <select class="slds-select" id="select-01"> <option value="selVal">Please select</option> <option>Hot</option> <option>Warm</option> <option>Cold</option> </select> </div> </div> </div> <aura:iteration items = "{!Rating}" var = "Rat" > <c:AccountRatingTile Acc = "{!Rat}" /> </aura:iteration> </aura:component>Clientside Controller:
({ AccRating : function(AccCom, event, helper) { var selValVal = AccCom.find("v.selVal"); console.log(selValVal); var RatParam = selValVal.get("v.value"); var searchAction =AccCom.get("c.AccMethod"); searchAction.setParam("RatParam",RatParam); searchAction.setCallback(this,function(resp){ AccCom.set("v.Acc",resp.getReturnValue()); }); $A.enqueueAction(searchAction); } })
App:
<aura:application extends = "force:slds"> <c:AccountRating /> </aura:application>
Thanks.
Try like below,
AccountRating cmp, controller AccountRatingTile
regards
All Answers
Try like below,
AccountRating cmp, controller AccountRatingTile
regards
Check once below sample code :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/