SHARE
TWEET

Untitled

a guest Sep 15th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UI -
  2. <aura:component >
  3.     <aura:attribute name="pageNumber" type="Integer" default="1"/>
  4.     <aura:attribute name="lastPageNumber" type="Integer"/>
  5.     <div class="slds-button-group" role="group">
  6.       <button class="slds-button slds-button_neutral" onclick="{!c.onButtonClick}" disabled="{!v.pageNumber == 1}">First</button>
  7.       <button class="slds-button slds-button_neutral" onclick="{!c.onButtonClick}" disabled="{!v.pageNumber == 1}">Previous</button>
  8.       <button class="slds-button slds-button_neutral" onclick="{!c.onButtonClick}" disabled="{!v.pageNumber == v.lastPageNumber}">Next</button>
  9.       <lightning:button label="Last" title="Last" onclick="{! c.onButtonClick}" disabled="{!v.pageNumber == v.lastPageNumber}"/>
  10.       <div>Page: {!v.pageNumber} of {!v.lastPageNumber}</div>
  11.        
  12.     </div>
  13. </aura:component>
  14.  
  15. Controller -
  16. ({
  17.     onButtonClick : function(cmp, event, helper) {
  18.         debugger;
  19.         //console.log('Button Name: '+event.target.innerHTML);
  20.         var buttonType;
  21.         if(event.getSource)
  22.             buttonType = event.getSource().get("v.label");
  23.         else
  24.             buttonType = event.target.innerHTML;
  25.         console.log('Button Name: '+buttonType);
  26.         if(buttonType == 'First') {
  27.             cmp.set("v.pageNumber",1);
  28.         }
  29.         else if(buttonType == 'Previous') {
  30.             cmp.set("v.pageNumber",cmp.get("v.pageNumber")-1);
  31.         }
  32.         else if(buttonType == 'Next') {
  33.             cmp.set("v.pageNumber",cmp.get("v.pageNumber")+1);
  34.         }
  35.         else if(buttonType == 'Last') {
  36.             cmp.set("v.pageNumber",cmp.get("v.lastPageNumber"));
  37.         }
  38.         console.log('page number: '+cmp.get("v.pageNumber"));        
  39.     }
  40. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top