【发布时间】:2017-07-30 17:48:42
【问题描述】:
我无法通过访问 $scope.girdOptions.api.setColumnDefs 来更新 ag-gird girdOptions columnDefs。
我想要实现的是按具有不同值的表分组。
var masterColumnDefs = [
{headerName: 'Name', field: 'name',
// left column is going to act as group column, with the expand / contract controls
cellRenderer: 'group',
// we don't want the child count - it would be one each time anyway as each parent
// not has exactly one child node
cellRendererParams: { suppressCount: true }
},
{headerName: 'Account', field: 'account'},
{headerName: 'Calls', field: 'totalCalls'},
{headerName: 'Minutes', field: 'totalMinutes', cellFormatter: minuteCellFormatter}
];
cellRenderer: 'group' 代码是他们为处理分组而内置的代码,因此此示例包含在展开时在行内渲染网格。
虽然他们可以通过枢轴菜单选项动态地进行分组,但我需要在行内呈现网格,因此我在响应中得到的 JSON 类似于 Plunkr 中的 rowData。
因此,我无法使用透视选项进行动态分组。
我这里要解决的问题是通过修改上面的masterColumnDefs来更新它
` masterColumnDefs = [
{headerName: 'Name', field: 'name'
},
{headerName: 'Account', field: 'account',
// left column is going to act as group column, with the expand / contract controls
cellRenderer: 'group',
// we don't want the child count - it would be one each time anyway as each parent
// not has exactly one child node
cellRendererParams: { suppressCount: true }},
{headerName: 'Calls', field: 'totalCalls'},
{headerName: 'Minutes', field: 'totalMinutes', cellFormatter: minuteCellFormatter}
];`
并使用
更新 gridOptions$scope.gridOptions.api.setColumnDefs(masterColumnDefs);
没有什么能帮到我。
可能其他解决方案也可以实现该功能,但我不明白。
注意事项:
- 我有一个类似于 plunkr 中的模拟 JSON 和 JSON 中的数组并稍后由函数修改的响应。
- 扩展组时需要渲染网格。
- 我需要通过枢轴企业设施或按钮按另一个值分组,以通过访问 api 来更新 columnDefs,就像在 plunkr 中的方式一样。
任何想法都会有很大帮助。
【问题讨论】:
标签: javascript angularjs ag-grid