我在這裏丟失了什麼?網格渲染,沒有錯誤,空行......我檢查和JSON是罰款來這一點$scope.gridOptions.data = response['data'];
這似乎是它的渲染空數組並從未得到實際的數據...UI網格Angular,網格渲染但不顯示數據
app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.myData = [];
$scope.loading = true;
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{ name: 'Id', field: 'PK_Inspection' },
{ name: 'Employee Id', field: 'EmployeeId' },
{ name: 'Employee Name', field: 'EmployeeName' },
{ name: 'Equipment Id', field: 'EquipmentId' },
{ name: 'Equipment Name', field: 'EquipmentName' },
{ name: 'Sequence', field: 'SequenceName' },
{ name: 'Details', field: 'SequenceDetails' },
{ name: 'Type', field: 'SequenceTypeName' },
{ name: 'Shift', field: 'ShiftName' },
{ name: 'Status', field: 'StatusName' }
],
data:[]
};
$http.get('/Home/GetAllData')
.then(function (response) {
$scope.gridOptions.data = response['data'];
})
.catch(function (err) {
$scope.loading = false;
console.log("Error Receiving Data.");
})
.finally(function() {
$scope.loading = false;
console.log($scope.gridOptions.data);
});
}]);
數據傳遞到$scope.gridOptions.data
:
[
{
"PK_Inspection": 1,
"EmployeeId": "4433112",
"EmployeeName": "",
"EquipmentId": "1122113",
"EquipmentName": "",
"SequenceName": "UNIT 1",
"SequenceDetails": "Bent, Dented, Broken, Torn or Deformed Parts.",
"SequenceTypeName": "Visual Inspection",
"ShiftName": "Day",
"StatusName": "OK"
},
{
"PK_Inspection": 2,
"EmployeeId": "4433112",
"EmployeeName": "",
"EquipmentId": "1122113",
"EquipmentName": "",
"SequenceName": "UNIT 2",
"SequenceDetails": "Charge, Water Levels, Vent Caps in place, Power Disconnect works.",
"SequenceTypeName": "Visual Inspection",
"ShiftName": "Day",
"StatusName": "OK"
}
]
這裏的HTML:
<div ng-controller="MainCtrl">
<i class="fa fa-spinner fa-spin text-center" ng-show="loading"></i>
<div id="mainGrid" ui-grid="gridOptions" ui-grid-edit class="myGrid"></div>
</div>
截圖
你能提供的響應數據的例子嗎? – Phil 2015-02-11 06:10:39
@Phil我用響應數據更新了問題。 – Dayan 2015-02-11 12:42:45