Jestem nowy angularjs technology.I'm za pomocą AG-siatkę i chcą, aby wyświetlić kolumnę dynamicznieJak wyświetlić kolumnę dynamicznie przy użyciu AG-siatkę
moje dane JSON jest:
[{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}]
moje wyjście Oczekuje Expected Output
istniejący kod znajduje się poniżej
$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;
});
}
Istniejące wyjściowa jest podana poniżej Existing Output
W jaki sposób można osiągnąć mój oczekiwany wynik z istniejącego wyjścia
Przepraszam. To moja wina, format json jest zły. zaktualizowałem moje dane JSON. Ale w rzeczywistości to nie problem. Możesz mi pomóc w rozwiązaniu problemu. –