0
我正在使用ag-grid with angularjs。所以在控制器中,我使用sql DB源填充網格行。爲此,我正在調用返回對象數組的webapi調用。以下是代碼。ag-grid沒有顯示任何數據
var module = angular.module("crud", ["agGrid"]);
module.controller("crudCtrl", function ($scope, $http) {
var columnDefs = [
{ headerName: "Roll No", field: "RollNo", editable: true },
{ headerName: "Name", field: "Name", editable: true },
{ headerName: "Place", field: "PlaceName", editable: true },
{ headerName: "Birth Date", field: "dob", editable: true }
];
$scope.gridOptions = {
columnDefs: columnDefs,
rowData: [],
headerHeight: 42,
rowHeight: 32
};
$http.get("api/Student/GetAllStudents").then(function (response) {
$scope.gridOptions.rowData = response.data;
}, function (error) {
console.log('Oops! Something went wrong while saving the data.')
});
});
但是當我運行該頁面時,它不顯示任何數據。當我調試並看到它返回response.data中的記錄作爲數組[12]的對象數組。但它在網格中顯示不一樣。如果不是response.data,而是指定我自己的數組,類似於返回的響應,那麼它將呈現數據。那麼,問題在哪裏?
thanx ...但在我的情況下它得到解決了$ scope.gridOptions.api.setRowData(res.data); – ghetal