我正在使用 Angular Ui-grid。尝试在其中实现多级嵌套。有人已经在uiGrid github中提出了这个问题。但该解决方案似乎不起作用。
我已经像这样更改了 JSON 。我正在尝试形成嵌套的子网格。
下面是我的代码
$scope.gridOptions = {
expandableRowTemplate: 'expandableRowTemplate.html',
enableGridMenu: true,
expandableRowHeight: 150,
paginationPageSizes: [5, 10, 15],
paginationPageSize: 5,
//subGridVariable will be available in subGrid scope
expandableRowScope: {
subGridVariable: 'subGridScopeVariable'
}
}
$scope.gridOptions.columnDefs = [
{ name: 'id', enableHiding: false },
{ name: 'name' },
{ name: 'age' },
{ name: 'address.city' }
];
$http.get('http://private-7a7085-getfriends1.apiary-mock.com/getfriends')
.success(function (data) {
for (i = 0; i < data.length; i++) {
//for(i = 0; i < 50; i++){
data[i].subGridOptions = {
columnDefs: [{ name: "Id", field: "id" }, { name: "Name", field: "name" }, { name: "Age", field: "id" }, { name: "Address", field: "name" }],
data: data[i].friends,
expandableRowTemplate: 'expandableRowTemplate1.html',
enableGridMenu: true,
expandableRowHeight: 150
}
for (j = 0; j < data[i].friends.length; j++) {
data[i].subNestedGridOptions = {
columnDefs: [{ name: "Id", field: "id" }, { name: "Name", field: "name" }, { name: "Age", field: "id" }, { name: "Address", field: "name" }],
data: data[i].friends[j].friends
}
}
}
$scope.gridOptions.data = data;
});
和第二级嵌套 html(expandableRowTemplate1.html) 看起来像
<div ui-grid="row.entity.subNestedGridOptions" style="height:150px;"></div>
当我将数据传递给二级嵌套网格的 ui-grid 时,它会抛出未定义。
到目前为止,有没有人成功实现了超过 2 或 3 个级别的可扩展 UI 网格。如果是,请分享 plunker 或 fiddle 或详细解释将非常有帮助!