Posts

Lightning Component to show Date, Time and Greeting

Image
 Lightning Aura Component that shows current Date and Time with Greeting. Screenshot: - Component: - ViewDateTimeAndGreeting.cmp <aura:component implements="flexipage:availableForAllPageTypes"> <aura:handler name="init" value="{!this}" action="{!c.handleTime}" />          <aura:attribute name="hour" type="Integer" />     <aura:attribute name="minute" type="Integer" />     <aura:attribute name="period" type="String" />     <aura:attribute name="day" type="String" />     <aura:attribute name="date" type="Integer" />     <aura:attribute name="month" type="String" />     <aura:attribute name="year" type="String" />          <aura:attribute name="greet" type="String" default="Hello !" />          <aura:attribute name=...

Thank you page with simple HTML and CSS

Image
 A simple Thank You page using HTML and CSS Screenshot: - Code: - <!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> .top-banner{ background: #f0f8ff; font-size: 25px; padding: 3px 0px 3px 0px; text-align: center; font-weight: 500; font-family: sans-serif; } .center-banner{ margin-top: 40px; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; padding: 8px 0px 8px 0px; font-family: sans-serif; } .app-table{ margin-left: auto; margin-right: auto; } </style> </head> <body> <div class="top-banner"> <p>Thanks for writing to us, we will get back to you.</p> </div> <div class="center-banner"> <table class="app-table"> <tr> <td>You can also follow us on</td> <td><a href="https://www.linkedin.com/company/...

Lightning Component with Custom Search and Sorting

Image
Lightning aura component with custom search and sorting. Screenshots: - Component: - <aura:component controller="getProducts"> <!--handler-->     <aura:handler name="init" value="{!this}" action="{!c.doInit}" />          <!--attributes-->     <aura:attribute name="products" type="List" />          <aura:attribute name="queryTerm" type="String" default="" />     <aura:attribute name="isSearching" type="Boolean" default="false" />          <aura:attribute name="sortBy" type="String" default="name" />     <aura:attribute name="sortOrder" type="String" default="asc" />          <aura:attribute name="showSpinner" type="Boolean" default="false" />          <!--spinner-->     <aura:if isTrue="{!v.showSpinner}...

Lightning component with drag and drop feature

Image
A simple lightning component explains how to create drag and drop elements in lightning. Screenshots: - Component: - Component_A.cmp <aura:component > <!--attribute-->          <!--component markup-->     <div class="slds-text-heading_large slds-p-left_medium">Component A</div>          <div class="slds-grid">         <div class="slds-col slds-size_3-of-12 one" draggable="true" ondragstart="{!c.dragStart}">             <div class="slds-text-heading_small">This is first box</div>         </div>                  <div class="slds-col slds-size_3-of-12 two" draggable="true" ondragstart="{!c.dragStart}">             <div class="slds-text-heading_small">This is second box</div>         </di...

Lightning component with drag and drop functionality to delete records.

Image
In the following example, we will see how to implement 'drag and drop' feature in lightning component . We will see a small example to implement this, I am using standard contact object and I will try to fetch the contacts in my component and delete one contact by dragging and dropping the contact into a recycle bin . Screenshots: - Apex: - public class getContact { @AuraEnabled public static List<Contact> getContactList(){ List<Contact> con = [SELECT Id, Name, Email FROM Contact]; return con; } @AuraEnabled public static void deleteContact(String contactId){ contact[] con = [SELECT Id,Name FROM Contact WHERE Id =: contactId]; try{ delete con; } catch (DmlException e){ } } } Component: - ListOfContact.cmp <aura:component controller="getContact"> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:attribute name="contact" type="Object" /> ...

Lightning component to display chart using Chart.Js

Image
In the following example, we are using Chart.Js plugin to implement Chart in our lightning component . I am using Account and it's related Contact for showing how many contact are related to one account graphically. Screenshots: - Apex: -   public class getContact {     @AuraEnabled     public static List<Contact> getContactList(){         List<Contact> con = [SELECT Id, Name, Email, Account.Name FROM Contact];         return con;     } } Component: - <aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="getContact"> <!--attributes-->     <ltng:require scripts="{!$Resource.chartNew}" afterScriptsLoaded="{!c.scriptsLoaded}"/> <!--include chart JS plugin from static resource-->          <aura:handler name="init" value="{!this}" action="{!c.init}" /> <!--init method for getting contacts and acco...