You need to sign in to do that
Don't have an account?
KTsfdc
I want to show pop of contact record using lightning component
When I click on any contact record from table after that pop should be open and view that record in popup using lightning component. How to acheive
Here is my code:
Component:
Helper:
Here is my code:
Component:
<aura:component controller="ListofContacts" implements="force:hasRecordId,flexipage:availableForAllPageTypes" access="global" > <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:attribute name="contacts" type="List"/> <div class="slds-box slds-theme_shade slds-theme_alert-texture"> <div class="slds-text-heading--medium " style="margin-top: 10px;margin-left: 16px;"><b> Search Your Contact</b></div> <div style="margin-left: 16px;margin-bottom: 5px;"> <lightning:input class="slds-form-element slds-form-element__control" style="width:160px;float:left;" placeholder="Search Contact..." type="search" value="{!v.searchKeyword}" aura:id="searchField" onchange="{!c.Search}"/><br/> </div><br/> <table class="tble slds-table slds-table_bordered slds-max-medium-table_stacked-horizontal slds-border_left slds-border_right slds-border_bottom slds-border_top" style="margin-left: 15px;margin-top: 10px;"> <thead> <tr class="slds-text-heading--small"> <th scope="col" class="slds-text-title_caps"><span class="slds-truncate ">Id</span></th> <th scope="col" class="slds-text-title_caps"><span class="slds-truncate ">Name</span></th> <th scope="col" class="slds-text-title_caps"><span class="slds-truncate ">Email</span></th> <th scope="col" class="slds-text-title_caps"><span class="slds-truncate ">Phone</span></th> </tr> </thead> <tbody> <aura:iteration var="ct" items="{!v.contacts}" indexVar="index"> <tr> <th scope="row" class="slds-text-title_caps">{!ct.Id}</th> <td ><div class="slds-truncate"><a>{!ct.Name}</a></div></td> <td ><div class="slds-truncate">{!ct.Email}</div></td> <td ><div class="slds-truncate">{!ct.Phone}</div></td> </tr> </aura:iteration> </tbody> </table> </div> </aura:component>JS Controller:
({ doInit : function(component, event, helper) { var action= component.get("c.getAllContacts"); action.setCallback(this, function(result){ var state=result.getState(); if(state === "SUCCESS" && component.isValid()){ component.set("v.contacts",result.getReturnValue()); } }); $A.enqueueAction(action); }, Search: function(component, event, helper) { var searchField = component.find('searchField'); helper.SearchHelper(component, event); }, })
Helper:
({ SearchHelper : function(component,event) { var action = component.get("c.getAllContactsByName"); action.setParams({ 'searchKeyWord': component.get("v.searchKeyword") }); action.setCallback(this, function(result) { var state = result.getState(); if(state === "SUCCESS") { component.set("v.contacts",result.getReturnValue()); } }); $A.enqueueAction(action); }, handleClick: function(component, event, helper) { //Close the Modal Window component.find("overlayLib").notifyClose(); } })
I trust you are doing very well.
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Component:
Controller:
CSS:
Apex:
Screenshots:
1.
2.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
All Answers
I trust you are doing very well.
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Component:
Controller:
CSS:
Apex:
Screenshots:
1.
2.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas