AG Grid:找不到agGroupCellRenderer

时间:2018-02-01 03:15:56

标签: ag-grid ag-grid-react

我升级了ag-grid& ag-grid-react to 14.2.0,但我仍然收到这个警告:

ag-grid:寻找组件[agGroupCellRenderer],但找不到它。

我的专栏定义:

let columnDefs= [
    {headerName: 'Name', field: 'userName', width:163, cellRenderer:'agGroupCellRenderer'},
    {headerName: 'Job Title', field: 'jobTitle', width:143},
]

我在这里缺少什么?请帮忙。谢谢!

4 个答案:

答案 0 :(得分:1)

我认为您应该使用components属性将字符串(agGroupCellRenderer)映射到角度组件(AgGroupCellRendererCompoennt)

gridOptions = {
    ... 
    components: {
        agGroupCellRenderer: AgGroupCellRendererCompoennt
    }
}

更多信息,请点击https://www.ag-grid.com/javascript-grid-cell-rendering/

答案 1 :(得分:1)

对于那些在Angular 8中收到此消息“ ag-Grid:正在寻找组件”的用户,请检查是否在HTML页面上引用了它。在我的代码中,我在HTML文件中缺少一些参考代码。这是一个可以帮助某人的粗略示例:

示例

组件文件:

import { AgGroupCellRendererComponent } from 
'../../global/components/agGroupCellRenderer.component';

columnDefs= [{headerName: 'Name', field: 'userName', width:163, 
cellRenderer:'agGroupCellRenderer'}]

frameworkComponents: any;
constructor() {
    this.frameworkComponents = {
      agGroupCellRenderer: AgGroupCellRendererComponent,
    };
}

HTML文件:

<ag-grid-angular
  style="width: 100%; height: 500px;"
  class="ag-theme-balham"
  [gridOptions]="gridOptions"
  [rowData]="rowData"
  [frameworkComponents]="frameworkComponents"
> 

答案 2 :(得分:1)

确保包含在您的组件文件中:

public class Test
{

    public void test()
    {
        Func<int, long> realSquareFunc = (val) => val * val;
        Type[] methodArgs = { typeof(int) };

        DynamicMethod squareIt = new DynamicMethod(
            "SquareIt",
            typeof(long),
            methodArgs,
            typeof(Test).Module)
        ;

        ILGenerator il = squareIt.GetILGenerator();
        il.Emit(OpCodes.Ldarg_0); // Save parameter on stack
        il.Emit(OpCodes.Call, realSquareFunc.Method); // Call function with input as parameter
        il.Emit(OpCodes.Ret); // Return value from function call before

        var myMethod = (Func<int, long>)squareIt.CreateDelegate(realSquareFunc.GetType());
        var result = myMethod.Invoke(4); // Should be 16 (4*4)
    }

}

,并将其保存在您的html文件中:

 frameworkComponents = {agGroupCellRenderer: AGroupCellRenderer}
 context = { componentParent: this }
.....
{headerName: 'Name', field: 'userName', width:163, cellRenderer:'agGroupCellRenderer'}

答案 3 :(得分:0)

升级到15.0.0时警告消失