最初数据为空,但稍后在setPagingData()方法中,它会更新。检查控制台中的数据,$ scope.Data正在更新。但是网格中的数据没有得到更新。任何帮助..
class GridViewController {
constructor( $scope,$timeout ) {
$scope.gridView = {
show : true
};
$scope.columnDefs = [
{field : 'Id' , displayName : 'ID'},
{field : 'name' , displayName : 'Name'}
];
$scope.fData = [
{
"Id" : "123",
"name": "John"
}
]
$scope.filterOptions = {
filterText: "",
useExternalFilter: true
};
$scope.totalServerItems = 0;
$scope.Data = [];
$scope.pagingOptions = {
pageSizes: [250, 500, 1000],
pageSize: 5,
currentPage: 1
};
$scope.setPagingData = function(data, page, pageSize){
var pagedData = data.slice((page - 1) * pageSize, page * pageSize);
$scope.Data = angular.copy(pagedData);
console.log($scope.Data);
$scope.totalServerItems = data.length;
if (!$scope.$$phase) {
$scope.$apply();
}
$scope.$apply();
};
$scope.getPagedDataAsync = function (pageSize, page, searchText) {
$timeout(function () {
var data;
if (searchText) {
var ft = searchText.toLowerCase();
data = $scope.fData.filter(function(item) {
return JSON.stringify(item).toLowerCase().indexOf(ft) != -1;
});
$scope.setPagingData(data,page,pageSize);
} else {
$scope.setPagingData($scope.fData,page,pageSize);
}
}, 100);
};
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);
$scope.$watch('pagingOptions', function (newVal, oldVal) {
if (newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) {
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText);
}
}, true);
$scope.$watch('filterOptions', function (newVal, oldVal) {
if (newVal !== oldVal) {
$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage, $scope.filterOptions.filterText);
}
}, true);
//console.log($scope.Data.length);
$scope.gridOptions = {
data : 'Data',
columnDefs : $scope.columnDefs,
enablePaging: true,
showFooter: true,
totalServerItems: $scope.totalServerItems,
pagingOptions: $scope.pagingOptions,
filterOptions: $scope.filterOptions,
rowHeight: 28,
plugins: [new ngGridFlexibleHeightPlugin()]
};
gridViewScope = $scope;
}
}
orderFlowApp.controller('GridViewController', GridViewController);
答案 0 :(得分:0)
是的,ng-grid似乎存在问题。尝试这样的事情。
this.apigClient = apigClientFactory.newClient({
accessKey: "anything",
secretAccessKey: "anything",
sessionToken: "nothing",
region: 'eu-central-1'