Last active
May 8, 2018 15:30
-
-
Save anilsomasundaran/14132bb8ee0a0c9932d5ddf1d8bb7bc1 to your computer and use it in GitHub Desktop.
This file contains 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 ContactAuraController { | |
@AuraEnabled | |
Public static List<Contact> getContactList(){ | |
//get all contact list | |
List<Contact> conList = [SELECT Id, Name, Account.Name, Phone, Email FROM Contact LIMIT 1]; | |
return conList; | |
} | |
} |
This file contains 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="ContactAuraController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > | |
<!--Declare Event Handlers--> | |
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/> | |
<!--Declare Attributes--> | |
<aura:attribute name="contactList" type="list" /> | |
<aura:attribute name="isSelectAll" type="boolean" default="false"/> | |
<aura:attribute name="recdId" type="String" /> | |
<aura:attribute name="previousSelection" type="String" default="" /> | |
<div class="slds-m-around_xx-large"> | |
<h1 class="slds-text-heading--medium">Contacts</h1> | |
<br/> | |
<!--Contact List Table--> | |
<table class="slds-table slds-table--bordered slds-table--cell-buffer" role="grid"> | |
<thead> | |
<tr class="slds-text-title--caps"> | |
<th> | |
<!--<label class="slds-checkbox"> | |
<ui:inputCheckbox value="{!v.isSelectAll}" change="{!c.handleSelectedContacts}" aura:id="selectAll"/> | |
<span class="slds-checkbox__faux" /> | |
<span class="slds-form-element__label"></span> | |
</label>--> | |
</th> | |
<th scope="col"> | |
<div class="slds-truncate" title="Name">Name</div> | |
</th> | |
<th scope="col"> | |
<div class="slds-truncate" title="Account">Account</div> | |
</th> | |
<th scope="col"> | |
<div class="slds-truncate" title="Phone">Phone</div> | |
</th> | |
<th scope="col"> | |
<div class="slds-truncate" title="Email">Email</div> | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
<aura:iteration items="{!v.contactList}" var="con"> | |
<tr> | |
<th> | |
<label class="slds-checkbox"> | |
<ui:inputCheckbox aura:id="checkContact" name="test" value="" text="{!con.Id}" change="{!c.onCheckboxChange}"/> | |
<!--<lightning:input aura:id="{!con.Id}" type="checkbox" label=" " name="{!con.Id}" checked="false" onchange="{!c.onCheckboxChange}"/>--> | |
<span class="slds-checkbox--faux" /> | |
<span class="slds-form-element__label"></span> | |
</label> | |
</th> | |
<th scope="row"> | |
<div class="slds-truncate" title="{!con.Name}">{!con.Name}</div> | |
</th> | |
<td> | |
<div class="slds-truncate" title="{!con.Account.Name}">{!con.Account.Name}</div> | |
</td> | |
<th scope="row"> | |
<div class="slds-truncate" title="{!con.Phone}">{!con.Phone}</div> | |
</th> | |
<td> | |
<div class="slds-truncate" title="{!con.Email}">{!con.Email}</div> | |
</td> | |
</tr> | |
</aura:iteration> | |
</tbody> | |
</table> | |
<div> | |
<br/> | |
<!-- <lightning:button label="Submit" class="slds-button_brand" onclick="{!c.handleSelectedContacts }" /> --> | |
</div> | |
</div> | |
</aura:component> |
This file contains 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
({ | |
//get Contact List from apex controller | |
doInit : function(component, event, helper) { | |
var action = component.get("c.getContactList"); | |
action.setParams({ | |
}); | |
action.setCallback(this, function(result){ | |
var state = result.getState(); | |
if (component.isValid() && state === "SUCCESS"){ | |
component.set("v.contactList",result.getReturnValue()); | |
} | |
}); | |
$A.enqueueAction(action); | |
}, | |
//Select all contacts | |
//Process the selected contacts | |
onCheckboxChange : function (component,event,helper){ | |
//debugger; | |
var checkboxes = component.find('checkContact'); | |
var value =false; | |
if (!Array.isArray(checkboxes)) { | |
checkboxes.set('v.value', value); | |
} else { | |
checkboxes.forEach(function(cb) { | |
cb.set('v.value', value); | |
}); | |
} | |
event.getSource().set("v.value",true); | |
//text attribute of the checbox contains the value of contact Id | |
var contactId = event.getSource().get("v.text"); | |
console.log("ContactId"+contactId); | |
//sets the value to recordId attribute defined in the component view part | |
component.set("v.recdId",contactId); | |
console.log("record Id", component.get("v.recdId")); | |
}, | |
getSelectedName: function (cmp, event,helper) { | |
debugger; | |
var selectedRows = event.getParam('selectedRows'); | |
for (var i = 0; i < selectedRows.length; i++){ | |
// alert(selectedRows[i].Id); | |
cmp.set('v.recdId', selectedRows[i].Id); | |
var RecordID = cmp.get("v.recdId"); | |
alert('RecordID'+RecordID); | |
} | |
}, | |
closeCreationWindow : function (component,event,helper) { | |
console.log("Button clicked"); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment