Reputation: 73
In ag-grid I'm using the cellRendererFramework for rendering a particular cell. I'm able to get the cell values from parent grid component using the params property. Now, my requirement is to update this params from my cellRendererFramework component and refresh my parent grid component. I tried using the @Output annotation to emit an event with updated data to the parent grid component. However, I'm not able to subscribe to this event from the grid. Is there some other way to achieve this objective?
My development environment is Angular2 and I'm using v9.1.0 of ag-grid.
Thank you.
Upvotes: 1
Views: 9464
Reputation: 51
import { GridOptions} from 'ag-angular'
parent component
gridOptions:GridOptions;
constructor(){
this.gridOptions={
context:{
componentParent:this
}
};
}
updateEmployee(id:any){
//something
}
<ag-grid-angular [gridOptions]="gridOptions"
></ag-grid-angular>
childCOmponent
agInit(params: any): void {
this.params=params;
this.data = params.data.name;
}
onEdit(){
this.params.context.componentParent.updateEmployee(this.params.data.id);
}
<button (click)="onEdit">Edit</button>
Upvotes: 5
Reputation: 285
I have similar question as yours.
I used cellRendererFramework and set some button inside a component. After that I want to click button and pass value to parent component.
Finally, I found a solution like this. Simple Dynamic Component
Hope this link can help you so.
Upvotes: 0