-
-
Save salesforce-casts/d4585fcb3fcab78342b244e23abe4801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="force:appHostable" controller="customDataTablesController"> | |
<aura:handler name="init" value="{! this }" action="{! c.doInit }" /> | |
<aura:attribute name="allAccounts" type="Account[]" /> | |
<lightning:card title="Custom Data Table"> | |
<table class="slds-table slds-table_cell-buffer slds-table_bordered"> | |
<thead> | |
<tr class="slds-line-height_reset"> | |
<th class="slds-text-title_caps" scope="col"> | |
<div class="slds-truncate" title="Account Name">Account Name</div> | |
</th> | |
<th class="slds-text-title_caps" scope="col"> | |
<div class="slds-truncate" title="Account Type">Account Type</div> | |
</th> | |
<th class="slds-text-title_caps" scope="col"> | |
<div class="slds-truncate" title="Industry">Industry</div> | |
</th> | |
<th class="slds-text-title_caps" scope="col"> | |
<div class="slds-truncate" title="Rating">Rating</div> | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
<aura:iteration items="{! v.allAccounts }" var="account"> | |
<tr class="slds-hint-parent"> | |
<td data-label="{!account.Name}" scope="row"> | |
<div class="slds-truncate" title="{!account.Name}">{!account.Name}</div> | |
</td> | |
<td data-label="{!account.Type}"> | |
<div class="slds-truncate" title="{!account.Type}">{!account.Type}</div> | |
</td> | |
<td data-label="{!account.Industry}"> | |
<div class="slds-truncate" title="{!account.Industry}">{!account.Industry}</div> | |
</td> | |
<td data-label="{!account.Rating}"> | |
<div class="slds-truncate" title="{!account.Rating}">{!account.Rating}</div> | |
</td> | |
</tr> | |
</aura:iteration> | |
</tbody> | |
</table> | |
</lightning:card> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(component, event, helper) { | |
var action = component.get("c.fetchAccounts"); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (state === "SUCCESS") { | |
component.set( "v.allAccounts", response.getReturnValue()); | |
} | |
else if (state === "INCOMPLETE") { | |
} | |
else if (state === "ERROR") { | |
var errors = response.getError(); | |
if (errors) { | |
if (errors[0] && errors[0].message) { | |
console.log("Error message: " + | |
errors[0].message); | |
} | |
} else { | |
console.log("Unknown error"); | |
} | |
} | |
}); | |
$A.enqueueAction(action); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment