I have this below query . Where i am trying to display Opportunity name and products associated to it in a lightning tree-grid structure.
The issue i am facing is i am able to display opportunity name . But i am unable to display product name and family
List < Opportunity > opps = [ SELECT Id, Name, StageName,
( SELECT Id, Product2.Name, Product2.Family FROM OpportunityLineItems )
FROM Opportunity WHERE Id IN: oppsIds];
HTML -
<lightning-tree-grid hide-checkbox-column columns={gridColumns} data={gridData} key-field="Id">
</lightning-tree-grid>
JS -
gridColumns = [{
type: 'text',
fieldName: 'Name',
label: 'Opportunity Name'
},
{
type: 'text',
fieldName: 'StageName',
label: 'Stage'
},
{
type: 'text',
fieldName: 'Product2.Name',
label: 'ProductName'
},
{
type: 'text',
fieldName: 'Product2.Family',
label: 'Product Family'
}
];
wire method returning the data
if ( data ) {
var tempData = JSON.parse( JSON.stringify( data ) );
for ( var i = 0; i < tempData.length; i++ ) {
var cons = tempData[ i ][ 'OpportunityLineItems' ];
console.log('cons ' + JSON.stringify( cons ))
if ( cons ) {
tempData[ i ]._children = cons;
delete tempData[ i ].OpportunityLineItems;
}
}
this.gridData = tempData;
this.allRows = tempData;