To display lookup field, include the lookup field from the object and add it to the response
public with sharing class GetAllOpportunities {
@AuraEnabled(cacheable=true)
public static List<DataTableWrapper> getAllOpps() {
List<Opportunity> listOpp = [SELECT Id, Name ,StageName, CloseDate
FROM Opportunity Order By Name asc];
List<DataTableWrapper> response = new List<DataTableWrapper>();
for(Opportunity opp : listOpp){
DataTableWrapper obj = new DataTableWrapper();
obj.oppId = opp.Id;
obj.name = opp.Name;
obj.nameUrl = '/'+opp.Id;
obj.stageName = opp.StageName;
obj.closeDate = opp.CloseDate;
response.add(obj);
}
return response;
}
private class DataTableWrapper {
@AuraEnabled
public Id oppId {get;set;}
@AuraEnabled
public String name {get;set;}
@AuraEnabled
public String nameUrl {get;set;}
@AuraEnabled
public String stageName {get;set;}
@AuraEnabled
public Date closeDate {get;set;}
}
}
For picklist values, you can refer to the below sample code
The following examples are taken from below posts
https://salesforce.stackexchange.com/questions/257065/hyperlink-record-name-lwc-datatable
https://success.salesforce.com/answers?id=9063A000000pg0xQAA
To display lookup field, include the lookup field from the object and add it to the response
For picklist values, you can refer to the below sample code
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. Thank You!
Anudeep
I need working full sample code please