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
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
access="global"
controller="AccountController">
<aura:attribute name="data" type="Object"/>
<aura:attribute name="columns" type="List"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="pageNumber" type="Integer" default="1"/>
<aura:attribute name="pageSize" type="Integer" default="10"/>
({
/*
* This finction defined column header
* and calls getAccounts helper method for column data
* editable:'true' will make the column editable
* */
doInit : function(component, event, helper) {
component.set('v.columns', [
{label: 'Name', fieldName: 'Name', type: 'text',
actions:[
({
getAccounts : function(component, helper) {
var action = component.get("c.getAccountsWithOffset");
action.setStorable();
var pageSize = component.get("v.pageSize").toString();
var pageNumber = component.get("v.pageNumber").toString();
action.setParams({
'pageSize' : pageSize,
'pageNumber' : pageNumber
public class AccountController {
@AuraEnabled
public static List<Account> getAccountsWithOffset(String pageSize, String pageNumber){
Integer ps = Integer.valueOf(pageSize);
Integer pn = Integer.valueOf(pageNumber)-1;
List<Account> accounts = [SELECT
Id, Name, Phone, Rating, My_Custom_Field__c, Active__c
FROM Account LIMIT :Integer.valueOf(ps) OFFSET :(ps*pn)];
return accounts;
public class AuraIfTester
{
/**
* Function to get all AuraIFTester records
* */
@AuraEnabled
public static List<AuraIfTester__c> getRecords()
{
return [SELECT
Id, //Record ID
<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}">
({
doInit : function(component, event, helper) {
helper.onInit(component, event, helper);
}
})
({
/**
* 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();
<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>
({
doInit : function(component, event, helper) {
helper.onInit(component, event, helper);
}
})