This file contains hidden or 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
Show hidden characters
{ | |
/** | |
* My custom code snippets for Salesforce which makes life of a developer easy :) | |
* @author - Manish Choudhari | |
*/ | |
"Package Creator": { | |
"scope": "xml", | |
"prefix": "package", | |
"body": [ |
This file contains hidden or 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 AccountController { | |
@AuraEnabled | |
public static List<Account> getAccounts(){ | |
return [SELECT | |
Id, Name, Phone, Rating, My_Custom_Field__c, Active__c | |
FROM Account LIMIT 10]; | |
} | |
} |
This file contains hidden or 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 page reference and set record id, object name attribute | |
* @author Manish Choudhari | |
* */ | |
doInit: function(component, event, helper) { | |
//getting page reference from pageReference attribute supplied by lightning:isUrlAddressable interface | |
var myPageRef = component.get("v.pageReference"); | |
//get parameter from state | |
var recordId = myPageRef.state.c__recordId; |
This file contains hidden or 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 implements="lightning:isUrlAddressable,force:appHostable,flexipage:availableForAllPageTypes"> | |
<aura:attribute type="String" name="recordId" /> | |
<aura:attribute type="String" name="objectName" /> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<lightning:card title="URL Addressable Component"> | |
<lightning:recordForm | |
recordId="{!v.recordId}" | |
objectApiName="{!v.objectName}" | |
layoutType="Full" |
This file contains hidden or 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 Selected Value from AutoComplete Component | |
* @author Manish Choudhari | |
* */ | |
getSelectedValue : function(component, event, helper) { | |
//find autocomplete component using aura id | |
const autoCompleteComponent = component.find("account-record"); | |
if(autoCompleteComponent){ | |
//get selected option from auto complete component's selectedOption attribute |
This file contains hidden or 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 implements="flexipage:availableForAllPageTypes"> | |
<aura:attribute type="String" name="selectedValue" /> | |
<lightning:card title="AutoComplete Demo"> | |
<lightning:layout multipleRows="true"> | |
<lightning:layoutItem size="12" padding="around-small"> | |
<c:AutoComplete aura:id="account-record" label="Account" objectApiName="Account" idFieldApiName="Id" valueFieldApiName="Name" /> | |
</lightning:layoutItem> | |
<lightning:layoutItem size="12" padding="around-small"> | |
<lightning:button label="Get Selected Value" variant="brand" onclick="{!c.getSelectedValue}" /> |
This file contains hidden or 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
import { LightningElement, track } from 'lwc'; | |
//Let's configure the columns of the data table | |
const columns = [ | |
//Key here is cellAttributes object for Particular column | |
{label: 'Name', fieldName: 'name', type: 'text'}, | |
//Diet type column can accept a css class. The css class name should be passed in field name "dietClass" from server | |
{label: 'Diet Type', fieldName: 'diet', type: 'text', cellAttributes: { class: { fieldName: 'dietCSSClass' }}}, | |
{label: 'Blood Group', fieldName: 'bloodGroup', type: 'text'}, | |
//likewise fvtColor column can also have a css class in fvtColorCSSClass field |
This file contains hidden or 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
<template> | |
<!--A very basic data table--> | |
<lightning-datatable | |
key-field="id" | |
data={data} | |
columns={columns} | |
is-loading={tableLoadingState}> | |
</lightning-datatable> | |
</template> |
NewerOlder