Posts

Showing posts from April, 2018

Using Component.find vs Document.getElementById to Dynamically Hide or Show Content in Lightning Components

Image
Business Scenario: To dynamically Show or Hide content in Lightning Components. Using "Document.getElementById" Below are Component and Controller code to show or hide content by using Document.getElementById HideShow.cmp <aura:component implements= "force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access= "global" > < ! --Set component attribute--> <aura:attribute name= "valSet" type = "Set" /> <center> < ! --Button to display Set values--> <lightning:button onclick= "{!c.getSetValues}" label= "Set Values" /> </center> < ! --Construct HTML Table using SLDS--> <table class= "slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout" > <thead> <tr c...

Collections In Lightning Components

Image
Collections are building blocks for any object oriented programming language. In Apex we use LIST, SET, MAP collection types in order to work with records! Here in this blog, we are going look at some basic code on using Collection Types in context with Lightning Components..... First we create an Apex Controller with two methods to return List and Map respectively. We will use these methods to access from our Lighting Component and display them on the Home Page. public class LightningCollectionTypes { @AuraEnabled public static List < Account > lghtList() { List < Account > lstAccnts = [SELECT Id, Name FROM Account LIMIT 22 ]; return lstAccnts; } @AuraEnabled public static Map < Id, Account > lghtMap() { Map < ID, Account > m = new Map < ID, Account > ([SELECT Id, Name FROM Account LIMIT 22 ]); return m; } } LIST Below are component and...