Skip to main content
1 of 3
Jeff Callahan
  • 463
  • 11
  • 29

LWC - Run Event on Child when Datable Row Selected on Parent

I am trying to run an Event on my Child Component when the Datable row is selected on my Parent Component.
When I run with the code below I am getting an error

Here is the Event code from my Child Component

handleCancel(event){
    const inputFields = this.template.querySelectorAll( 'lightning-input-field' );
    if ( inputFields ) {
        inputFields.forEach( field => {
        field.reset();
        this.showSaveButton = false;
        } );   
    }
}

Here is the Event code from my Parent Component

handleRowSelection(event){
        var selectedRows=event.detail.selectedRows;
        if(selectedRows.length>1)
        {
            var el = this.template.querySelector('lightning-datatable');
            selectedRows=el.selectedRows=el.selectedRows.slice(1);
            event.preventDefault();
            return;
        }
        this.werRecordId = selectedRows[0].Id;
        this.template.querySelector('c-work-experience-record-page').handleCancel(event.target.value);
        this.werSelectedRow=true;
    }
Jeff Callahan
  • 463
  • 11
  • 29