Guest User

Untitled

a guest
Oct 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
  2. access="global"
  3. controller="AccountController">
  4.  
  5. <aura:attribute name="data" type="Object"/>
  6. <aura:attribute name="columns" type="List"/>
  7. <aura:attribute name="recordId" type="String"/>
  8.  
  9. <aura:attribute name="pageNumber" type="Integer" default="1"/>
  10. <aura:attribute name="pageSize" type="Integer" default="20"/>
  11. <aura:attribute name="isLastPage" type="Boolean" default="false"/>
  12. <aura:attribute name="resultSize" type="Integer" default="0"/>
  13. <!-- attribute to hold selected all rows -->
  14. <aura:attribute name="selection" type="List" />
  15. <!-- attribute to check if the page has changed or not -->
  16. <aura:attribute name="hasPageChanged" type="Boolean" />
  17.  
  18. <!-- This attribute will hold the update records from data table-->
  19. <aura:attribute name="updatedRecord" type="Object[]" />
  20.  
  21. <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
  22.  
  23.  
  24. <!-- You must define keyField as 'Id' to save the record back in Salesforce
  25. 'onsave' attribute will executed when user clicks on save button -->
  26.  
  27. <lightning:card title="Datatable With Pagination">
  28. <lightning:layout multipleRows="true" horizontalAlign="center">
  29. <lightning:layoutItem padding="around-small" size="12">
  30. <lightning:button label="Make Selection" onclick="{!c.makeSelection}"/>
  31. </lightning:layoutItem>
  32. <lightning:layoutItem padding="around-small" size="12">
  33. <!-- onrowselection fires when a new is selected or unselected, or page has changed with new rows in it -->
  34. <lightning:datatable
  35. aura:id="accountDataTable"
  36. columns="{! v.columns }"
  37. data="{! v.data }"
  38. keyField="Id"
  39. hideCheckboxColumn="false"
  40. selectedRows = "{!v.selection}"
  41. onrowaction="{! c.handleRowAction }"
  42. onrowselection ="{!c.onRowSelection}"/>
  43. </lightning:layoutItem>
  44. <lightning:layoutItem padding="around-small" flexibility="auto">
  45. <lightning:button label="Prev" iconName="utility:chevronleft" iconPosition="left"
  46. onclick="{!c.onPrev}" disabled="{! v.pageNumber == 1}"/>
  47. <span class="slds-p-horizontal_small">
  48. Page {!v.pageNumber} | Showing records from {! ((v.pageNumber-1)*v.pageSize)+' to '+((v.pageNumber-1)*v.pageSize+v.resultSize)}
  49. </span>
  50. <lightning:button label="Next" iconName="utility:chevronright" iconPosition="right"
  51. disabled="{! v.isLastPage}" onclick="{!c.onNext}"/>
  52. </lightning:layoutItem>
  53. </lightning:layout>
  54. </lightning:card>
  55.  
  56. </aura:component>
Add Comment
Please, Sign In to add comment