Skip to content

Instantly share code, notes, and snippets.

@olopsman
Created October 2, 2019 09:43
Show Gist options
  • Save olopsman/189faf11716232072e18c67064826a45 to your computer and use it in GitHub Desktop.
Save olopsman/189faf11716232072e18c67064826a45 to your computer and use it in GitHub Desktop.
Lightning Component
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="dataTableSampleREST">
<!-- attributes -->
<aura:attribute name="recordId" type="String"></aura:attribute>
<aura:attribute name="mydata" type="Object"></aura:attribute>
<aura:attribute name="mycolumns" type="List"></aura:attribute>
<aura:attribute name="noResults" type="String"></aura:attribute>
<!-- handlers-->
<aura:handler name="init" value="{! this }" action="{! c.init }"></aura:handler>
<article aura:id="gridContainer" class="slds-card slds-card_boundary">
<lightning:card title="Documents" iconName="standard:document">
<div class="slds-card__header slds-grid">
<aura:if isTrue="{!not(empty(v.mydata))}" >
<!-- the container element determine the height of the datatable -->
<lightning:datatable keyField="id"
data="{! v.mydata }"
columns="{! v.mycolumns }"
hideCheckboxColumn="true"
sortable="false"
onrowaction="{!c.getDocument}"></lightning:datatable>
</aura:if>
<aura:if isTrue="{!empty(v.mydata)}" >
<p>{!v.noResults}</p>
</aura:if>
</div>
</lightning:card>
</article>
</aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment