$scope.gridOptions = { columnDefs: [],enableFilter: true,rowData: null,rowSelection: 'multiple',rowDeselection: true };
当我从服务器检索数据时:
$scope.customColumns = []; $http.post('/Home/GetProducts',{ tableName: 'TABLE_PRODUCT' }).success(function (data) { angular.forEach(data.Columns,function (c) { $scope.customColumns.push( { headerName: c.Name,field: c.Value,width: c.Width } ); }); $scope.gridOptions.columnDefs = $scope.customColumns; $scope.gridOptions.rowData = data.Products; $scope.gridOptions.api.onNewRows(); }).error(function () { });
注意:这里c是来自服务器的列对象.
当动态生成列并将其分配给$scope.gridOptions.columnDefs时,会出现空格,但是$scope.customColumns数组将填充右边生成的列对象.请帮助我是这个bug还是我做错了?