I am getting this error from Chrome when running an ag-grid application. Basically, I have following
export class CustomHeader implements IHeaderAngularComp {
private params: any;
@ViewChild('menuButton', { read: ElementRef }) public menuButton;
agInit(params): void {
this.params = params;
}
onMenuClicked() {
this.params.showColumnMenu(this.menuButton.nativeElement);
}
refresh(params: IHeaderParams): boolean {
return true;
}
}
...
ColumnDefs = {
...
{
field: "A column", editable: false, sortable: false, width: 90,
type: 'stringColumn', centered: true, pinned: 'left',
headerComponent: CustomHeader,
headerComponentParams: {
template: `
<div ref="eLabel" class="lmn-form-group">
<input ref="eCheck" type="checkbox">
<span>Use This</span>
</div>
`
}
},
...
}
The Chrome says it does not recognize this CustomHeader:
Could not find ponent class CustomHeader { agInit(params) { this.params = params; } onMenuClicked() { this.params.showColumnMenu(this.menuButton.nativeElement); } refresh(params) { return true; } }, did you forget to configure this ponent?"
Is there anything I am missing?
I am getting this error from Chrome when running an ag-grid application. Basically, I have following
export class CustomHeader implements IHeaderAngularComp {
private params: any;
@ViewChild('menuButton', { read: ElementRef }) public menuButton;
agInit(params): void {
this.params = params;
}
onMenuClicked() {
this.params.showColumnMenu(this.menuButton.nativeElement);
}
refresh(params: IHeaderParams): boolean {
return true;
}
}
...
ColumnDefs = {
...
{
field: "A column", editable: false, sortable: false, width: 90,
type: 'stringColumn', centered: true, pinned: 'left',
headerComponent: CustomHeader,
headerComponentParams: {
template: `
<div ref="eLabel" class="lmn-form-group">
<input ref="eCheck" type="checkbox">
<span>Use This</span>
</div>
`
}
},
...
}
The Chrome says it does not recognize this CustomHeader:
Could not find ponent class CustomHeader { agInit(params) { this.params = params; } onMenuClicked() { this.params.showColumnMenu(this.menuButton.nativeElement); } refresh(params) { return true; } }, did you forget to configure this ponent?"
Is there anything I am missing?
Share Improve this question asked Jul 29, 2021 at 2:27 rainbowrainbow 431 silver badge4 bronze badges 1-
Is there a
@Component
decorator on it? – Aviad P. Commented Jul 29, 2021 at 6:03
2 Answers
Reset to default 6Have you seen the example in the documentation?
Note that you also need to provide the [frameworkComponents]
grid property so that the grid knows to use the header ponent:
this.frameworkComponents = { agColumnHeader: CustomHeader };
If you e here in 2022 and you are not using the latest version ag-grid, do check the correct version documents here:
https://www.ag-grid./archive/
For me at version 25.3, still need to use frameworkComponents as @Shuheb said, but the latest version 27.3 docs do not have this property any more.
As the 25.3 doc says, There are two ways to register custom ponents:
- By name.
- Direct reference.
- By Name
export class AppComponent {
frameworkComponents: [
'cubeComponent': CubeComponent
];
columnDefs: [
{
headerName: "Cube",
field: "value",
cellRenderer: 'cubeComponent',
}
]
//...other properties & methods
}
- By Direct Reference
export class AppComponent {
columnDefs: [
{
headerName: "Cube",
field: "value",
cellRendererFramework: CubeComponent,
}
]
//...other properties & methods
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743780837a4505765.html
评论列表(0条)