Skip to content

Instantly share code, notes, and snippets.

View Sunil02kumar's full-sized avatar

Sunil Kumar Sunil02kumar

View GitHub Profile
@RestResource(urlMapping='/RestAPIDemo/*')
global class SK_RestAPIDemoController {
@HttpGet
global static List<Account> searchAccounts() {
String cName = RestContext.request.params.get('searchString');
string searchName = '%' + cName + '%';
List<Account> accList = new List<Account>();
accList = [ Select ID, Name, Type,Industry, BillingCountry from Account where Name Like : searchName];
return accList;
}
@Sunil02kumar
Sunil02kumar / SK_AuraIfCmp.cmp
Last active August 29, 2017 15:01
Lightning Component to display Aura:if tag behavior
<aura:component >
<aura:attribute name="displayedSection" type="string" default=""/>
<div>
<b> This component is going to explain aura:if tag functionality</b>
</div>
<lightning:button label="Display Section 1" variant="brand" onclick="{!c.displaySection1}"/>
<lightning:button label="Display Section 2" variant="brand" onclick="{!c.displaySection2}"/>
<aura:if isTrue="{!v.displayedSection == 'section1'}">
<div aura:id="firstsection">
<lightning:input type="text" label="Section 1 input" name="sec1"
@Sunil02kumar
Sunil02kumar / SK_SLDSShowHide.cmp
Created August 29, 2017 15:00
Lightning Component to display slds-show and slds-hide behavior
<aura:component >
<aura:attribute name="displayedSection" type="string" default=""/>
<div>
<b> This component is going to explain div slds show-hide functionality</b>
</div>
<lightning:button label="Display Section 1" variant="brand" onclick="{!c.displaySection1}"/>
<lightning:button label="Display Section 2" variant="brand" onclick="{!c.displaySection2}"/>
<div aura:id="firstsection" class="{!if(v.displayedSection == 'section1','slds-show','slds-hide')}">
<div>
<b> First Div Section</b>
<aura:application extends="force:slds">
<c:SK_LightningTreeCmp ltngcurrentRecId="0019000000ld4kO"
ltngSobjectname="Account"
ltngParentFieldAPIName="ParentId"
ltngLabelFieldAPIName="Name"
ltngHierarchyHeader="Account Hierarchy"/>
<c:SK_LightningTreeCmp ltngcurrentRecId="5009000000GJkJG"
ltngSobjectname="Case"
<aura:component controller="SK_DemoSF1EventsCmpController" implements="force:appHostable" >
<aura:attribute name="recList" type="List" />
<aura:attribute name="menu" type="List" default="View,Edit" description="Optional Menu Items"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
<aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>
<div class="slds-align--absolute-center">
<lightning:spinner aura:id="spinner" variant="brand" size="large" class="slds=hide"/>
</div>
<apex:page sidebar="false" standardStylesheets="false" docType="html-5.0" id="sk" showHeader="false">
<head>
<apex:slds />
</head>
<body class="slds-scope">
<div class="slds-grid slds-wrap" id="fileSelectionPopUpDiv">
<div class="slds-col slds-size--1-of-1 slds-small-size--1-of-2 slds-medium-size--1-of-2 slds-col">
<div class="slds-align_absolute-center">
@Sunil02kumar
Sunil02kumar / SK_ChartJsCmp.cmp
Last active January 30, 2018 02:56
Using Chartjs in Lightning Components
<aura:component controller="SK_ChartJsCmpController">
<aura:attribute name="ltngChartData" type="Object"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div class="slds-grid slds-wrap">
<div class="slds-size--1-of-1 slds-medium-size--1-of-1 slds-large-size--1-of-1" >
<div class="slds-card__body slds-card__body_inner" aura:id="lineChartSection"/>
</div>
<div class="slds-size--1-of-1 slds-medium-size--1-of-1 slds-large-size--1-of-1" >
<div class="slds-card__body slds-card__body_inner" aura:id="horrizontalBarChartSection"/>
@Sunil02kumar
Sunil02kumar / SK_DataTableFreezeHeaderDemoApp.app
Created February 12, 2018 16:41
Datatable header Freeze Demo
<aura:application extends="force:slds">
<c:SK_DataTableFreezeHeaderDemoCmp />
</aura:application>
public class SK_WrapperSortUtility {
//We will sort wrapper list based on count value
//using bubble sort
public static List<SK_sortUtilityTestWrapper> sortWrapperList(List<SK_sortUtilityTestWrapper> recList,string sortType){
List<SK_sortUtilityTestWrapper> sortedList = new List<SK_sortUtilityTestWrapper>();
system.debug('******sortedList before sorting in '+sortType+':'+recList);
if(recList.size()>0){
sortedList = recList;
if(sortType.equalsIgnoreCase('DESC')){
public class SK_sortUtilityTestWrapper implements Comparable{
public string category{get;set;}
public decimal count{get;set;}
public SK_sortUtilityTestWrapper(string ss,decimal sk){
this.category=ss;
this.count=sk;
}
// Compare wrapper based on the count value.
public Integer compareTo(Object compareTo) {