Difference Between Clint Side Controller And Server Side Controller Lightning Components
DIFFERENCE BETWEEN CLINT SIDE CONTROLLER AND SERVER SIDE CONTROLLER LIGHTNING COMPONENTS
Server Side Components :
JS Controller :
doInit: function(component, event, helper) {
var page = component.get("v.page") || 1;
var recordToDisply = component.find("recordSize").get("v.value");
helper.getAccounts(component, page, recordToDisply, component.get('v.selectedTabsoft'), component.get("v.isAsc"));
},
previousPage: function(component, event, helper) {
var recordToDisply = component.find("recordSize").get("v.value");
component.set("v.page", component.get("v.page") - 1);
helper.getAccounts(component, component.get("v.page"), recordToDisply,component.get('v.selectedTabsoft'), component.get("v.isAsc"));
},
gotoFirstPage : function(component, event, helper) {
component.set("v.page",1);
var recordToDisply = component.find("recordSize").get("v.value");
helper.getAccounts(component, 1, recordToDisply,component.get('v.selectedTabsoft'), component.get("v.isAsc"));
},
gotoLastPage : function(component, event, helper) {
component.set("v.page",component.get("v.pages"));
var recordToDisply = component.find("recordSize").get("v.value");
helper.getAccounts(component, component.get("v.pages"), recordToDisply,component.get('v.selectedTabsoft'), component.get("v.isAsc"));
},
nextPage: function(component, event, helper) {
var recordToDisply = component.find("recordSize").get("v.value");
component.set("v.page", component.get("v.page") + 1);
helper.getAccounts(component, component.get("v.page"), recordToDisply,component.get('v.selectedTabsoft'), component.get("v.isAsc"));
},
onSelectChange: function(component, event, helper) {
var page = 1
var recordToDisply = component.find("recordSize").get("v.value");
helper.getAccounts(component, page, recordToDisply,component.get('v.selectedTabsoft'), component.get("v.isAsc"));
}
Here We Can observe that each time on button click we are calling server side controller method .
So, we are querying the records but, according to salesforce governer limits we can use only 100 SOQL queries.If we exceed that limit we will get ERROR : System.LimitException.
Clint Side Component:
JS Controller :
({
doInit:function(component,event,helper){
helper.getContacts(component);
},
next:function(component,event,helper){
helper.next(component);
},
previous:function(component,event,helper){
helper.previous(component);
},
First:function(component,event,helper){
helper.First(component);
},
Last:function(component,event,helper){
helper.Last(component);
},
})
Here we no need to call server side controller method each time on the button click.
cons :
If the number of pages are increased , loading of record become slow.
very good
ReplyDelete