I'm setting up columns in angular-ui-grid like this:
$scope.columns.push({
displayName: 'TimeStamp', field: 'x', width: $scope.setGridColumnWidth(), sort: {
direction: uiGridConstants.DESC,
priority: 1
}
});
for (let i = 0; i < view.trend.getTagsList().length; i++)
$scope.columns.push({ displayName: view.trend.getTagsList()[i].getTitle(), field: 'y' + view.trend.getTagsList()[i].getId(), width: $scope.setGridColumnWidth() });
So if a trend contains 2 tags I'll get a ui-grid with the columns {x, y{id0}, y{id1} }
.
Now I'm trying to bind data using:
$scope.data = [];
let taglist = view.trend.getTagsList();
for (let i = 0; i < taglist.length; i++)
for (let n of taglist[i].getData())
$scope.data.push({ x: n.x, 'y' + taglist[i].getId(): n.y });
But I can't dynamically define an attribute in a json using 'y' + taglist[i].getId()
instead it wants a fixed value. Anyone knows a neat way to solve this?