项目作者: Manzanit0

项目描述 :
A reusable button packaged as a lightning component to export JS objects as a CSV
高级语言: JavaScript
项目地址: git://github.com/Manzanit0/CsvExporterButton.git
创建时间: 2018-08-20T11:37:00Z
项目社区:https://github.com/Manzanit0/CsvExporterButton

开源协议:Apache License 2.0

下载


CsvExporterButton

A reusable button packaged as a lightning component to export JS objects as a CSV

Use

  1. <aura:component description="ExampleComponent" controller="ExampleController">
  2. <!--
  3. - In your code, implement an Apex Controller which retrieves some records,
  4. - as well as the init action to populate the table.
  5. -->
  6. <!-- attributes -->
  7. <aura:attribute type="Object[]" name="allRecords" ></aura:attribute>
  8. <aura:attribute type="List" name="columns" ></aura:attribute>
  9. <!-- handlers-->
  10. <aura:handler name="init" value="{! this }" action="{! c.init }"></aura:handler>
  11. <aura:handler name="change" value="{!v.allRecords}" action="{!c.renderPage}" ></aura:handler>
  12. <lightning:card title="Example">
  13. <aura:set attribute="actions">
  14. <!-- Simply give the button the records and the export file name -->
  15. <c:CsvExporterButton records="{!v.allRecords}" fileName="export.csv" ></c:CsvExporterButton>
  16. </aura:set>
  17. <p class="slds-p-horizontal_small">
  18. <lightning:datatable
  19. keyField="id"
  20. data="{! v.allRecords }"
  21. columns="{! v.columns }"
  22. hideCheckboxColumn="true"></lightning:datatable>
  23. </p>
  24. </lightning:card>
  25. </aura:component>