With this code I don't get any value , I get the column with the name but their are no value , I don't now what is the mistake .
Some help please .
public with sharing class Action {
@AuraEnabled(cacheable=true)
public static List<Action__c> GetAction(String id) {
Obj__c obj= [Select Id from Obj__c where id =:id];
List<Plan__c> listAction = new List<Plan__c([SELECTid,Date__c,Theme__c,Name FROM Plan__c where Obj__c =:obj.Id]);
return listAction;
}
}
==> JS:
import { LightningElement,track,wire, api} from 'lwc';
import DATE from '@salesforce/label/c.DATE';
import THEME from '@salesforce/label/c.THEME';
import NAME from '@salesforce/label/c.NAME';
import GetAction from'@salesforce/apex/ClassAction.GetAction';
const columns = [
{ label: DATE, fieldName: 'date'},
{ label: THEME, fieldName: 'theme' },
{ label: ACTIONNAME, fieldName: 'name' }
];
export default class ActionLWC extends LightningElement {
@api recordId;
data = [];
columns = columns;
@wire(GetAction,{id:'$recordId'})
wiredGetAction({ error, data }) {
if (data) {
let fixeddata = [];
data.forEach((row) =>{
let dataline = Object.assign({}, row);
dataline.date = row.DATE;
dataline.theme = row.THEME;
dataline.name = row.ACTIONNAME;
})
this.data = fixeddata;
} else {
this.error = error;
}
}
}
==> HTML
<template>
<div style="height: 300px;">
<lightning-datatable
key-field="id"
data={data}
columns={columns}>
</lightning-datatable>
</div>
<template>