Today We’ll focus on creating custom data table using HTML table tag so here we have taken an example of opportunity record data to show in table.
we’ll create an apex class for query opportunity record
Apex Class
public class opportunityController {
@AuraEnabled
public static List opprtunityRecord(){
return [SELECT Id, Name, StageName, Amount, CloseDate FROM Opportunity];
}
}
Lightning Component
Opportunity Name
Amount
Stage
Close Date
{!opp.Name}
{!opp.Amount}
{!opp.StageName}
{!opp.CloseDate}
({
doInit : function(component, event, helper) {
var action = component.get("c.opprtunityRecord");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
component.set("v.opportunityRecord" ,response.getReturnValue());
}
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);
}
})
Output : -
