我正在使用角度Ui-grid。試圖實現多層嵌套。有人已經在uiGrid github提出這個問題。但是這個解決方案似乎不起作用。角度網格多層嵌套
我改變了JSON,如this。我正試圖形成嵌套的子網格。
下面是我的代碼
$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網格爲第二級網格嵌套,它拋出未定義。
有沒有人有成功,直到現在實現擴展UI網格多2或3級。如果是的話,請分享一下或者小提琴或者詳細的解釋會非常有幫助!
你可以請你爲你的例子創建plunker – ShaMoh