[英]display multidimensional array data angular ui-grid
I get next data structure array from api: 我从api获取下一个数据结构数组:
var data = [
{
id: 1,
name: 'test 1',
properties: [
{
id: 101,
name: 'custom 01'
},
{
id: 102,
name: 'custom 02'
}
]
},
{
id: 2,
name: 'test 2',
properties: [
{
id: 201,
name: 'custom 21'
},
{
id: 202,
name: 'custom 22'
}
]
}
and etc ...
]
I need to display data from nested array properties from each record. 我需要显示每个记录的嵌套数组属性中的数据。 This is how I'm trying to do: 这就是我想要做的:
$scope.gridOptions = {};
$scope.gridOptions.columnDefs = [];
$scope.gridOptions.data = data.data;
$scope.load = function (param) {
lovServices.events(param)
.then(function (response) {
var events = response.events;
for (var i = 0; i < events.length; i++) {
console.log(events[i].eventProperties)
$scope.gridOptions.data = events[i].eventProperties
}
})
}
});
console.log(events[i].eventProperties)
shows me the right data set, but the grid is still empty. console.log(events[i].eventProperties)
向我显示了正确的数据集,但网格仍然为空。 I appreciate if somebody could tell me where is my mistake? 我很高兴有人可以告诉我我的错误在哪里? Thanks in advance. 提前致谢。
In order to build your grid, you need to take a look at $scope.gridOptions.columnDefs = []; 为了构建网格,您需要查看$ scope.gridOptions.columnDefs = [];。
Check http://ui-grid.info/docs/#/tutorial/201_editable up, there is the example of how to define each column with the help of columnDefs property using your array of objects 检查http://ui-grid.info/docs/#/tutorial/201_editable ,这里有一个示例,该示例说明如何使用您的对象数组借助columnDefs属性来定义每个列
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.