-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy path191_horizontal_scrolling.ngdoc
98 lines (83 loc) · 2.93 KB
/
191_horizontal_scrolling.ngdoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@ngdoc overview
@name Tutorial: 191 Horizontal Scrolling
@description
Demonstrating scrolling with large amount of columns.
For better performance with the following example, you can choose to load the ui-grid.core.js file instead:
<pre>
<script src="/release/ui-grid.core.min.js"></script>
</pre>
@example
<example module="app">
<file name="app.js">
var app = angular.module('app', ['ngTouch', 'ui.grid']);
app.controller('MainCtrl', ['$scope', function ($scope) {
var colCount = 500;
var rowCount = 500;
var gridOptions = {};
function generateColumns() {
for (var colIndex = 0; colIndex < colCount; colIndex++) {
gridOptions.columnDefs.push({
name: 'col' + colIndex,
width: Math.floor(Math.random() * (120 - 50 + 1)) + 50
});
}
}
function generateData() {
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
var row = {};
for (var colIndex = 0; colIndex < colCount; colIndex++) {
row['col' + colIndex] = 'r' + rowIndex + 'c' + colIndex;
}
gridOptions.data.push(row);
}
}
function initialize() {
gridOptions = {
enableSorting: true,
fastWatch: true,
columnDefs: [],
data: []
};
generateColumns();
generateData();
$scope.gridOptions = gridOptions;
}
initialize();
}]);
</file>
<file name="index.html">
<div ng-controller="MainCtrl">
<strong>{{ gridOptions.columnDefs.length | number }} Columns with Random Widths</strong>
<br>
<br>
<div id="grid1" ui-grid="gridOptions" class="grid" ng-if="gridOptions"></div>
</div>
</file>
<file name="main.css">
.grid {
width: 500px;
height: 400px;
}
</file>
<file name="scenario.js">
var gridTestUtils = require('../../test/e2e/gridTestUtils.spec.js');
var GridObjectTest = require('../../test/e2e/gridObjectTestUtils.spec.js');
var grid1 = new GridObjectTest('grid1');
describe( '191 horizontal scrolling', function() {
gridTestUtils.firefoxReload();
it('check first couple of headers and cells - make sure grid has rendered', function () {
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 0, 'Col0' );
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 1, 'Col1' );
gridTestUtils.expectHeaderCellValueMatch( 'grid1', 2, 'Col2' );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 0, 'r0c0' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 0, 'r1c0' );
gridTestUtils.expectCellValueMatch( 'grid1', 2, 0, 'r2c0' );
gridTestUtils.expectCellValueMatch( 'grid1', 0, 1, 'r0c1' );
gridTestUtils.expectCellValueMatch( 'grid1', 1, 1, 'r1c1' );
});
// it('scroll right', function () {
// still working out how to get protractor to scroll an element
// });
});
</file>
</example>