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 extensible="true">
{!v.body}
</aura:component>
<aura:component controller="ListViewController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:attribute name="objName" type="String" />
<!--<aura:attribute name="objListView" type="String[]" />-->
<aura:attribute name="viewName" type="String" />
<div class="slds-box slds-theme_default">
<div class="slds-box">
<lightning:input aura:id="inputName" type="text" label="Enter Object Name:" required="true" />
<lightning:button variant="brand" label="Show List View" name="List View" onclick="{!c.showData}"/>
</div>
<br/><br/>
({
showData : function(component, event, helper) {
helper.showListViewData(component, event, helper);
},
onListViewChange : function(component, event, helper) {
helper.showRecordsData(component, event, helper);
},
})
({
showListViewData : function(component, event, helper) {
var strValue = component.find("inputName").get("v.value");
var setOptions = component.find("selectvalues");
component.set("v.objName", strValue);
var action = component.get("c.fetchListViews");
action.setParams({
"strObjName" : strValue
});
var optionValues = [];
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);
}
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;
}
}
.THIS .selected{
color:orange;
}
({
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 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'},
<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"/>