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"/>
<aura:attribute name="isLastPage" type="Boolean" default="false"/>
@choudharymanish8585
choudharymanish8585 / LightningPaginationController.js
Last active June 27, 2018 23:03
Lightning Server Controller Javascript
({
/*
* 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'},
{label: 'Phone', fieldName: 'Phone', type: 'phone'},
({
getAccounts : function(component, helper) {
var action = component.get("c.getAccountsWithOffset");
action.setStorable();
action.setParams({
'pageSize' : component.get("v.pageSize").toString(),
'pageNumber' : component.get("v.pageNumber").toString()
});
action.setCallback(this,function(response) {
var state = response.getState();
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)];
<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="allData" type="List"/>
<aura:attribute name="currentPageNumber" 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'},
{label: 'Phone', fieldName: 'Phone', type: 'phone'},
({
getAccounts : function(component, helper) {
var action = component.get("c.getLimitedAccounts");
action.setStorable();
action.setCallback(this,function(response) {
var state = response.getState();
if (state === "SUCCESS") {
console.log('Response Time: '+((new Date().getTime())-requestInitiatedTime));
component.set("v.totalPages", Math.ceil(response.getReturnValue().length/component.get("v.pageSize")));
component.set("v.allData", response.getReturnValue());
.THIS .selected{
color:orange;
}
public class AccountController {
@AuraEnabled
public static List<Account> getLimitedAccounts(){
List<Account> accounts = [SELECT
Id, Name, Phone, Rating, My_Custom_Field__c, Active__c
FROM Account ORDER BY CreatedDate LIMIT 2000];
return accounts;
}
}
public class ListViewController {
@AuraEnabled
public static list<String> fetchListViews(String strObjName) {
list<String> lstListViews = new list<String>();
if(strObjName != null && strObjName != ' ' && strObjName.length() != 0) {
list<ListView> lstViews = [Select Name,sobjectType From ListView where SobjectType =: strObjName];
for(ListView iterator:lstViews) {
lstListViews.add(iterator.Name);
}