gpt4 book ai didi

angularjs - 如何在 ui-grid angularjs 中启用水平滚动条

转载 作者:行者123 更新时间:2023-12-01 04:59:22 35 4
gpt4 key购买 nike

我正在使用 angularjs ui-grid,但我的网格上没有水平滚动条,并且所有列标题都混合在一起,因为网格中没有滚动条。
如何启用水平滚动条?

最佳答案

如果要始终显示水平滚动条,请在滚动条选项中设置 enableHorizontalScrollbaruiGridConstants.scrollbars.ALWAYS ,如果只想在需要的时候显示,设置为uiGridConstants.scrollbars.WHEN_NEEDED .

var app = angular.module('app', ['ngTouch', 'ui.grid'])

.controller('MainCtrl', ['$scope', 'uiGridConstants', function($scope, uiGridConstants) {

$scope.yourGridOptions = {
enableHorizontalScrollbar: uiGridConstants.scrollbars.WHEN_NEEDED, // Here!
enableVerticalScrollbar: uiGridConstants.scrollbars.WHEN_NEEDED,
columnDefs: [{
name: 'col1',
width:150
}, {
name: 'col2',
width:150
}, {
name: 'col3',
width:150
}, {
name: 'col4',
width:150
}],
data: [{
"col1": "aa",
"col2": "bb",
"col3": "cc",
"col4": "dd"
}, {
"col1": "aa",
"col2": "bb",
"col3": "cc",
"col4": "dd"
}, {
"col1": "aa",
"col2": "bb",
"col3": "cc",
"col4": "dd"
}]
};
}]);
.grid {
width: 200px;
height: 250px;
}
<!doctype html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular-touch.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular-animate.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
<script src="http://ui-grid.info/release/ui-grid.js"></script>
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>

<div ng-controller="MainCtrl">
<div id="grid1" ui-grid="yourGridOptions" class="grid"></div>
</div>


</body>
</html>

关于angularjs - 如何在 ui-grid angularjs 中启用水平滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34286477/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com