我是 angularjs 技术的新手。我正在使用 ag-grid 并希望动态显示列
我的json数据是:
[{Date:'12-12-2015',Name:'ammu',mark:20},{Date:'12-12-2015',Name:'appu',mark:24},{Date:'12-12-2015',Name:'anu',mark:27},{Date:'13-12-2016',Name:'ammu',mark:23},{Date:'13-12-2015',Name:'anu',mark:20}]
我的预期输出是 预期输出
现有代码如下
$scope.gridOptions = {
columnDefs: [],
enableFilter: true,
rowData: [],
rowSelection: 'multiple',
rowDeselection: true
};
$scope.customColumns = [];
Getdetails();
function Getdetails()
{
masterdataFactory.Getdetails()
.success(function (Student) {
f (Student.length != 0) {
for(var i=0;i<Student.length;i++) {
$scope.customColumns.push(
{
headerName: Student[i].Name,
field: "Mark",
headerClass: 'grid-halign-left'
}
);
};
$scope.gridOptions.columnDefs = $scope.customColumns;
$scope.gridOptions.rowData = Student;
$scope.gridOptions.api.setColumnDefs();
}
})
.error(function (error) {
$scope.status = 'Unable to load data: ' + error.message;
});
}
现有输出在现有输出下方给出
如何从现有输出达到我的预期输出