我有一个关于angulargrid的具体问题。我正在尝试实现一个功能,该功能将根据行数动态更改网格大小。 angulargrid目前不支持此功能。因此,我查看了与ag-grid具有相似功能的ng-grid。我的问题是可以以相同的方式在ag-grid中的ng-grid中实现gridHeight功能。像这样:
$scope.gridOptions.columnDefs = [
{ name:'id', width:50 },
{ name:'name', width:100, pinnedLeft:true },
{ name:'age', width:100, pinnedRight:true },
{ name:'address.street', width:150 },
{ name:'address.city', width:150 },
{ name:'address.state', width:50 },
{ name:'address.zip', width:50 },
{ name:'company', width:100 },
{ name:'email', width:100 },
{ name:'phone', width:200 },
{ name:'about', width:300 },
{ name:'friends[0].name', displayName:'1st friend', width:150 },
{ name:'friends[1].name', displayName:'2nd friend', width:150 },
{ name:'friends[2].name', displayName:'3rd friend', width:150 },
];
$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
.success(function(data) {
$scope.gridOptions.data = data;
});
$scope.randomSize = function () {
var newHeight = Math.floor(Math.random() * (300 - 100 + 1) + 300);
var newWidth = Math.floor(Math.random() * (600 - 200 + 1) + 200);
angular.element(document.getElementsByClassName('grid')[0]).css('height', newHeight + 'px');
angular.element(document.getElementsByClassName('grid')[0]).css('width', newWidth + 'px');
};
}]);