I want to implement a CellRenderer that can show/hide the cell it is attached to (let's call it ShowHideCellRenderer
).
I want this cell renderer to take a cell renderer (innerCellRenderer
) as a parameter which defines how the cell is rendered if it is visible.
In the ag-grid repository on github there is the GroupCellRenderer
which also uses an inner cell renderer:
let rendererPromise:Promise<ICellRendererComp>;
if (params.fullWidth == true) {
rendererPromise = this.cellRendererService.useFullWidthGroupRowInnerCellRenderer(this.eValue, params);
} else {
rendererPromise = this.cellRendererService.useInnerCellRenderer(this.params.colDef.cellRendererParams, columnToUse.getColDef(), this.eValue, params);
}
// retain a reference to the created renderer - we'll use this later for cleanup (in destroy)
if (rendererPromise) {
rendererPromise.then((value:ICellRendererComp) => {
this.innerCellRenderer = value;
})
}
But to do the same I need to somehow inject the CellRendererService
into my CellRenderer.
As I am using Angular for creation of the CellRenderer the @Autowired
decorator does not seem to work.
export class ShowHideCellRendererComponent implements ICellRendererAngularComp {
@Autowired('cellRendererService')
private cellRendererService: CellRendererService;
public agInit(params: any): void {
console.log(this.cellRendererService); // undefined
}
}
Doos somebody know how to inject the CellRendererService
into my angular cell renderer? Or do you have an idea how to implement an inner cell renderer in another way?