Angularjs Can‘;是否在ui网格中显示嵌套数组数据?
我想在ui网格中显示嵌套数据,例如数据:Angularjs Can‘;是否在ui网格中显示嵌套数组数据?,angularjs,multidimensional-array,angular-ui-grid,ui-grid,Angularjs,Multidimensional Array,Angular Ui Grid,Ui Grid,我想在ui网格中显示嵌套数据,例如数据: [ [ { id:1, name:“test1 }, { id:2, name:“test2 }, { id:3, name:“test3 }, { id:4, name:“test4 } ], [ { id:5, name:“test1 }, { id:6, name:“test2 }, { id:7, name:“test3 }, { id:8, name:“test4 } ] ] 我的想法是用rowTemplate修复它,
[
[
{ id:1, name:“test1 },
{ id:2, name:“test2 },
{ id:3, name:“test3 },
{ id:4, name:“test4 }
],
[
{ id:5, name:“test1 },
{ id:6, name:“test2 },
{ id:7, name:“test3 },
{ id:8, name:“test4 }
]
]
我的想法是用rowTemplate修复它,但我无法在rowTemplate.html中获取数据以对嵌套数据使用ng repeat,我将在同一行中显示多个数据,我不希望使用ui网格分组。
若数据是嵌套数组,我认为ui网格不会处理数据,若我将其配置为celltemplate行,则也是如此。entity为空且为空。
e、 g.rowTemplate.html
<div
ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid"
ui-grid-one-bind-id-grid="rowRenderIndex + '-' + col.uid + '-cell'"
class="ui-grid-cell"
ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }"
role="{{col.isRowHeader ? 'rowheader' : 'gridcell'}}"
ui-grid-cell>
<!— Here i would like to use ng-repeat for the nested data but
row.entity , colRenderIndex, col each is empty if i use {{
row.entity col, ... }} result is empty blank —>
</div>
请帮忙。这很简单。所有数据都驻留在数组的第一个对象中
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<div ng-app="app" ng-controller="ctrl">
<!--<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid"
ui-grid-one-bind-id-grid="rowRenderIndex + '-' + col.uid + '-cell'"
class="ui-grid-cell"
ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }"
role="{{col.isRowHeader ? 'rowheader' : 'gridcell'}}"
ui-grid-cell>-->
<!— Here i would like to use ng-repeat for the nested data but
row.entity , colRenderIndex, col each is empty if i use {{
row.entity col, ...
}} result is empty blank —>
{{data}}
<table>
<thead>
<tr>
<td>ID</td>
<td>Name</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in data[0]">
<td>{{row.id}}</td>
<td>{{row.name}}</td>
</tr>
</tbody>
</table>
<!--</div>-->
</div>
<script src="../lib/angular.js"></script>
<script>
var app = angular.module('app', []);
app.controller('ctrl', function ($scope) {
$scope.data=[
[
{ id:1, name:'test1' },
{ id:2, name:'test2' },
{ id:3, name:'test3' },
{ id:4, name:'test4' }
],
[
{ id:5, name:'test1' },
{ id:6, name:'test2' },
{ id:7, name:'test3'},
{ id:8, name:'test4' }
]
]
})
</script>
</body>
</html>
{{data}}
身份证件
名称
{{row.id}}
{{row.name}
var-app=angular.module('app',[]);
应用程序控制器('ctrl',函数($scope){
$scope.data=[
[
{id:1,名称:'test1'},
{id:2,名称:'test2'},
{id:3,名称:'test3'},
{id:4,名称:'test4'}
],
[
{id:5,名称:'test1'},
{id:6,名称:'test2'},
{id:7,名称:'test3'},
{id:8,名称:'test4'}
]
]
})
为什么必须使用嵌套数据?ui网格用于显示数据,您可以将的数据提取到ui网格的一层数组中。@huanfeng:不要无缘无故地向下投票,请重新阅读问题。好的,我的错误,除非您稍微编辑一下答案,否则系统不允许我还原更改。