forked from dojo/dojo1-dgrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree_expand.html
98 lines (92 loc) · 2.96 KB
/
tree_expand.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Tree Grid</title>
<meta name="viewport" content="width=570">
<style>
@import "../../dojo/resources/dojo.css";
@import "../css/skins/claro.css";
.container {
float: left;
margin: 10px;
width: 550px;
}
.dgrid {
width: 100%;
}
.field-bool {
width: 4em;
}
.field-type {
width: 5em;
}
.field-population {
width: 7em;
}
</style>
<script>
var start= new Date().getTime();
</script>
<script src="../../dojo/dojo.js"
data-dojo-config="async: true"></script>
<script>
require(["dojo/on", "dgrid/OnDemandGrid","dgrid/tree","dgrid/editor", "dgrid/Keyboard",
"dgrid/Selection", "dgrid/selector",
"dojo/_base/declare", "dojo/_base/array", "dgrid/test/data/base", "dojo/domReady!"],
function(on, Grid, tree, editor, Keyboard, Selection, selector, declare, arrayUtil){
var count = 0; // for incrementing edits from button under 1st grid
function nbspFormatter(value){
// returns " " for blank content, to prevent cell collapsing
return value === undefined || value === "" ? " " : value;
}
var StandardGrid = declare([Grid, Keyboard, Selection]);
arrayUtil.forEach([{
id: "asyncGrid",
store: testCountryStore
}, {
id: "syncGrid",
store: testSyncCountryStore
}], function(info){
var grid = window[info.id] = new StandardGrid({
store: info.store,
columns: [
tree({label: "Name", field:"name", sortable: false, shouldExpand: function(){ return true; }}),
editor({label: "Visited", field: "bool", sortable: false}, "checkbox"),
{label:"Type", field:"type", sortable: false},
{label:"Population", field:"population"},
{label:"Timezone", field:"timezone"}
]
}, info.id);
on(document.getElementById(info.id + "Save"), "click", function(){
grid.save();
});
on(document.getElementById(info.id + "Revert"), "click", function(){
grid.revert();
});
});
});
</script>
</head>
<body class="claro">
<p>This page tests auto-expansion of tree grids.</p>
<p><strong>NOTE:</strong> it is <em>strongly</em> recommended that you <em>only</em>
automatically expand for synchronous stores (or at least, stores which aren't
going back to the server for each child request); otherwise you are likely
to put a significant strain on your server, and the performance of the client
will suffer as a result.
</p>
<div class="container">
<h2>Auto-expanding tree grid, asynchronous store</h2>
<div id="asyncGrid"></div>
<button id="asyncGridSave">Save</button>
<button id="asyncGridRevert">Revert</button>
</div>
<div class="container">
<h2>Auto-expanding tree grid, synchronous store</h2>
<div id="syncGrid"></div>
<button id="syncGridSave">Save</button>
<button id="syncGridRevert">Revert</button>
</div>
</body>
</html>