Created
October 18, 2018 20:44
-
-
Save choudharymanish8585/7c0ea65f6b3c8dfffd166ca774f7dd13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
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 | |
}); | |
action.setCallback(this,function(response) { | |
var state = response.getState(); | |
if (state === "SUCCESS") { | |
console.log('Response Time: '+((new Date().getTime())-requestInitiatedTime)); | |
if(response.getReturnValue().length < component.get("v.pageSize")){ | |
component.set("v.isLastPage", true); | |
} else{ | |
component.set("v.isLastPage", false); | |
} | |
//Modify response to include the page number as well | |
//in the id attribute of each row | |
//This will help us to filter out the rows displayed on each page | |
response.getReturnValue().forEach(function(row) { | |
row.Id = row.Id+'-'+pageNumber; | |
}); | |
component.set("v.resultSize", response.getReturnValue().length); | |
component.set("v.data", response.getReturnValue()); | |
//Set selected rows with our selection attribute which has id of each attribute -->s | |
component.find("accountDataTable").set("v.selectedRows",component.get("v.selection")); | |
} | |
}); | |
var requestInitiatedTime = new Date().getTime(); | |
$A.enqueueAction(action); | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment