I am trying to automatically select(checkbox) the nested rows when selecting the parent row in a lightning-tree-grid.
It's my understanding that the selected-rows attribute on the lightning-tree-grid might be able to do this. I can't figure out if what I am doing is wrong, or I am not giving it what it needs to work. Ive included screenshots of 'most' of the code to help. I did find other supporting links that are related to my issue but I still cant get it to work.
lwc wire issue with select-rows
Selecte Children automatically when Select Parent
HTML
<div class="spinnerHolder">
<template if:true={isLoading}>
<lightning-spinner alternative-text="loading"></lightning-spinner>
</template>
<lightning-tree-grid
lwc:if={treeGridData.length}
class="results"
data-id="gridResult"
columns={gridColumns}
data={treeGridData}
key-field="contactName"
expanded-rows={expandedList}
selected-rows={selectedData}
onrowselection={selectRowHandler}
>
</lightning-tree-grid>
</div>
JS
@track selectedData = [];
selectRowHandler(event) {
let temp = [];
for (let i = 0; i < event.detail.selectedRows.length; i++) {
temp.push(event.detail.selectedRows[i]);
}
this.selectedData = temp;
console.log('selected Data', this.selectedData);
}
//probably dont need to show ALL of this but..
@wire(getResults, { filterString: '$bindFilters' })
contactsResult({ error, data }) {
this.gridisLoading = true;
this.contactsCount = 0;
this.offset = 0;
console.log(data);
if (data) {
const rawData = data;
this.contactsCount = rawData.length;
if (this.contactsCount === 0) {
this.gridisLoading = false;
this.activateSearch();
} else {
try {
this.initialData = dataHelper.transformDataObject(rawData);
this.downloadData = downloader.createCsvContent(rawData);
// console.log(this.downloadData);
if (this.missingPersons.length > 0) {
this.initialData = dataHelper.filterForMissingPerson(this.initialData, this.missingPersons);
this.downloadData = downloader.filterForMissingPersonDownload(this.downloadData, this.missingPersons);
}
this.sliceData();
} catch (e) {
this.handleError(e);
} finally {
this.gridisLoading = false;
this.activateSearch();
}
}
} else if (error) {
this.handleError(error);
}
this.gridisLoading = false;
this.activateSearch();
}


