function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dheeraj shokeenDheeraj shokeen 

Grant parent - Parent - Child in LWC Code, howz the logic Implement

A - Grant Parent
B-Parent
C- Child

Is there any logic to direclty 
Grand parent send the record to child
SubratSubrat (Salesforce Developers) 
Hello Dheeraj ,

In Lightning Web Component (LWC), you can communicate between components using events. To implement the logic where the grandparent sends a record to the child component, you need to follow these steps:

Define an event in the child component (C) that will receive the record from the grandparent component (A):
// childComponent.js
import { LightningElement, api } from 'lwc';

export default class ChildComponent extends LightningElement {
    @api record;

    // ...
}
Define an event in the parent component (B) that will receive the record from the grandparent component and pass it to the child component:
// parentComponent.js
import { LightningElement } from 'lwc';

export default class ParentComponent extends LightningElement {
    record;

    handleRecordReceived(event) {
        this.record = event.detail;
    }
}
<!-- parentComponent.html -->
<template>
    <c-child-component record={record}></c-child-component>
</template>
In the grandparent component (A), fire the event and pass the record to the parent component:
// grandparentComponent.js
import { LightningElement } from 'lwc';

export default class GrandparentComponent extends LightningElement {
    handleRecordSelected() {
        const selectedRecord = { /* Record data */ };

        const recordEvent = new CustomEvent('recordselected', {
            detail: selectedRecord
        });
        this.dispatchEvent(recordEvent);
    }
}
<!-- grandparentComponent.html -->
<template>
    <c-parent-component onrecordselected={handleRecordSelected}></c-parent-component>
</template>
In the above code, the grandparent component fires the recordselected event, which is handled by the parent component. The parent component then assigns the received record to its record property. Finally, the child component receives the record from the parent component by setting the record attribute using the @api decorator.

If this helps , please mark this as Best Answer.
Thank you.