Skip to content

Instantly share code, notes, and snippets.

View choudharymanish8585's full-sized avatar
💭
Never Settle

Manish Choudhari choudharymanish8585

💭
Never Settle
View GitHub Profile
({
fetchAccounts : function(component, event, helper) {
helper.getAllAccounts(component, helper);
},
})
<!--Exntends Base Component in Component Definition -->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="AccountController" access="global" >
<aura:attribute name="data" type="Account[]"/>
<!-- Including BaseJS script. Once loaded call fetchAccounts method -->
<ltng:require scripts="{!$Resource.BaseJS}"
afterScriptsLoaded="{!c.fetchAccounts}"/>
<aura:iteration items="{!v.data}" var="acc">
/*
* This method will call the server side action and will execute callback method
* it will also show error if generated any
* @param method (required) - Server side methos name
* @param callback (required) - Callback function to be executed on server response
* @param params (optional) - parameter values to pass to server
* @param setStorable(optional) - if true, action response will be stored in cache
* */
window.callServer = function(component, method, callback, params, setStorable) {
var action = component.get(method);
({
/**
* Retrieve the data from server
* call prepareData function to filter out unnecessary data
* */
onInit : function(component, event, helper) {
var action = component.get("c.getRecords");
action.setStorable();
action.setCallback(this,function(response) {
var state = response.getState();
({
doInit : function(component, event, helper) {
helper.onInit(component, event, helper);
}
})
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
controller="AuraIfTester"
access="global" >
<aura:attribute name="records" type="list" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<table style="border-color: grey; float: left;" border="1" cellspacing="4" cellpadding="4">
<tbody>
<aura:iteration items="{!v.records}" var="item">
<tr>
<td>{!item.Name}</td>
({
/**
* Retrieve the data from server
* */
onInit : function(component, event, helper) {
var action = component.get("c.getRecords");
action.setStorable();
action.setCallback(this,function(response) {
console.log('Response Time: '+((new Date().getTime())-requestInitiatedTime));
var state = response.getState();
({
doInit : function(component, event, helper) {
helper.onInit(component, event, helper);
}
})
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
controller="AuraIfTester"
access="global" >
<aura:attribute name="records" type="list" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<table style="border-color: grey; float: left;" border="1" cellspacing="4" cellpadding="4">
<tbody>
<aura:iteration items="{!v.records}" var="item">
<!-- Check if row needs to shown -->
<aura:if isTrue="{!item.Show_Me__c}">
public class AuraIfTester
{
/**
* Function to get all AuraIFTester records
* */
@AuraEnabled
public static List<AuraIfTester__c> getRecords()
{
return [SELECT
Id, //Record ID