Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Can‘;是否在ui网格中显示嵌套数组数据?_Angularjs_Multidimensional Array_Angular Ui Grid_Ui Grid - Fatal编程技术网

Angularjs Can‘;是否在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修复它,

我想在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修复它,但我无法在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:不要无缘无故地向下投票,请重新阅读问题。好的,我的错误,除非您稍微编辑一下答案,否则系统不允许我还原更改。