I have two components
parent-component,
lookup-table-component (child component, intended to be reused by multiple parents)|
lookup-table has a dataSource setup (for AG grid) which is supposed to call getRowData using a function of parent
getPageData(params)
As I am supposed to use this function in child
I am using the following approach.
Parent component
<parent-component
(rowClicked)="onGridRowClicked($event)"
[gridOptions]="gridOptions"
[callerClass]="this"
></parent component>
Child component
@Input() callerClass: any;
async createDatasource(): Promise<IServerSideDatasource> {
return {
getRows: async (params) => {
this.createRequestPayload(params.request);
const rowData = await this.callerClass.getPageData(
this.paging,
this.filterModel,
);
params.success({
rowData: rowData,
});
},
};
}
The code is working as expected but I want to know is there any better approach to achieve the same functionality.