February 2020

Salesforce

Navigating to a Page in Lightning Community using Custom Lightning Component

Create a Standard Page with the name "Sample":Add captionSample Code: Component1 cmp: <aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >              <aura:attribute name="Txt" type="String" default=""/>              <div class="slds-box slds-theme_default">                      This is component 1.<br/><br/>           <lightning:input type="text" value="{!v.Txt}" label="Enter some text"/><br/>           <lightning:navigation aura:id="navService"/>           <lightning:button label="Navigate" onclick="{!c.navigateToComTwo}"/>                  </div>          </aura:component>  Component1 JavaScript Controller: ({   ....

Salesforce

lightning:datatable with header and footer in Salesforce Lightning Component

Sample Code: Apex Class: public class AccountListController {              @AuraEnabled       public static List < Account > fetchAccts() {                  return [ SELECT Id, Name, Industry, Type FROM Account LIMIT 100 ];                  }          }   Lightning Component: <aura:component implements="force:appHostable" controller="AccountListController" >              <aura:attribute type="Account[]" name="acctList"/>       <aura:attribute name="mycolumns" type="List"/>              <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>                                        <lightning:card footer="Only 100 accounts records are loaded" title="Accounts">                   <p class="slds-p-horizontal_small">                                              <lightning:datatable data="{! v.acctList }"                                             columns="{! v.mycolumns }"                                             keyField="id"                                            hideCheckboxColumn="true"/>   ....