-
Notifications
You must be signed in to change notification settings - Fork 2
/
BigGridDemo.js
132 lines (115 loc) · 4.57 KB
/
BigGridDemo.js
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* ************************************************************************
*
* Qooxdoo DataGrid
*
* https://github.com/qooxdoo/qooxdoo
*
* Copyright:
* 2022-23 Zenesis Limited, https://www.zenesis.com
*
* License:
* MIT: https://opensource.org/licenses/MIT
*
* This software is provided under the same licensing terms as Qooxdoo,
* please see the LICENSE file in the Qooxdoo project's top-level directory
* for details.
*
* Authors:
* * John Spackman ([email protected], @johnspackman)
*
* *********************************************************************** */
qx.Class.define("qxl.datagrid.demo.biggrid.BigGridDemo", {
extend: qx.ui.container.Composite,
construct() {
super();
this.setLayout(new qx.ui.layout.VBox());
let grid = this.getQxObject("grid");
{
let comp = new qx.ui.container.Composite(new qx.ui.layout.Grid(5, 3));
comp.add(new qx.ui.basic.Label("Selection Style : "), { row: 0, column: 0 });
let rbComp = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
let rbRow = new qx.ui.form.RadioButton("Row");
rbComp.add(rbRow.set({ model: "row" }));
let rbCell = new qx.ui.form.RadioButton("Cell");
rbComp.add(rbCell.set({ model: "cell" }));
let rbArea = new qx.ui.form.RadioButton("Area");
rbComp.add(rbArea.set({ model: "area" }));
comp.add(rbComp, { row: 0, column: 1 });
let manager = new qx.ui.form.RadioGroup(rbRow, rbCell, rbArea);
manager.addListener("changeSelection", evt => {
let rb = evt.getData()[0];
grid.getSelectionManager().setSelectionStyle(rb.getModel());
});
manager.setSelection([rbCell]);
this.add(comp);
}
{
let comp = new qx.ui.container.Composite(new qx.ui.layout.Grid(5, 3));
comp.add(new qx.ui.basic.Label("Selection Mode : "), { row: 0, column: 0 });
let rbComp = new qx.ui.container.Composite(new qx.ui.layout.HBox(5));
let rbOne = new qx.ui.form.RadioButton("One").set({ model: "one" });
rbComp.add(rbOne);
let rbSingle = new qx.ui.form.RadioButton("Single").set({ model: "single" });
rbComp.add(rbSingle);
let rbMulti = new qx.ui.form.RadioButton("Multi").set({ model: "multi" });
rbComp.add(rbMulti);
let rbAdditive = new qx.ui.form.RadioButton("Additive").set({ model: "additive" });
rbComp.add(rbAdditive);
comp.add(rbComp, { row: 0, column: 1 });
let manager = new qx.ui.form.RadioGroup(rbOne, rbSingle, rbMulti, rbAdditive);
manager.addListener("changeSelection", evt => {
let rb = evt.getData()[0];
grid.getSelectionManager().setSelectionMode(rb.getModel());
});
manager.setSelection([rbMulti]);
this.add(comp);
}
this.add(grid, { flex: 1 });
},
objects: {
dataSource() {
// Create a massive data source with 1,000,000 rows and 10,000 columns
return new qxl.datagrid.demo.biggrid.DummyDataSource(1_000_000, 10_000);
},
grid() {
var dataSource = this.getQxObject("dataSource");
var columns = new qxl.datagrid.column.Columns();
for (let columnIndex = 0; columnIndex < dataSource.getNumColumns(); columnIndex++) {
// One column definition does not take uyp much space, so although we create 10,000
// columns that shouldnt be much of a problem
let column = new qxl.datagrid.column.TextColumn().set({
caption: qxl.datagrid.util.Labels.getColumnLetters(columnIndex),
path: "label",
minWidth: 80
});
columns.add(column);
}
var grid = new qxl.datagrid.ClippedScrollDataGrid(columns).set({
dataSource: dataSource
});
// Adjust the default selection style
grid.getSelectionManager().set({
selectionStyle: "cell",
selectionMode: "multi"
});
grid.addListener("changeSelection", evt => {
let sel = evt.getData();
console.log("Selection changed to " + sel.map(model => model.toString()).join(","));
});
return grid;
}
},
members: {
/**
* Called once to get the demo running
*/
async init() {
let dataSource = this.getQxObject("dataSource");
await dataSource.makeAvailable(new qxl.datagrid.source.Range([0, 0], [10, 10]));
let grid = this.getQxObject("grid");
const valueAt = (row, column) => dataSource.getModelForPosition(new qxl.datagrid.source.Position(row, column));
grid.getSelection().replace([valueAt(1, 0), valueAt(2, 0), valueAt(3, 0)]);
grid.getSelectionManager().setFocused(valueAt(4, 4));
}
}
});