2150 |
mathias |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
2 |
<html>
|
|
|
3 |
<head>
|
|
|
4 |
<title>dojox.Grid Sizing Example</title>
|
|
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
|
|
|
6 |
<style type="text/css">
|
|
|
7 |
@import "../../../dojo/resources/dojo.css";
|
|
|
8 |
@import "../_grid/tundraGrid.css";
|
|
|
9 |
|
|
|
10 |
/*
|
|
|
11 |
@import "../_grid/Grid.css";
|
|
|
12 |
body {
|
|
|
13 |
font-size: 0.9em;
|
|
|
14 |
font-family: Geneva, Arial, Helvetica, sans-serif;
|
|
|
15 |
}
|
|
|
16 |
*/
|
|
|
17 |
.heading {
|
|
|
18 |
font-weight: bold;
|
|
|
19 |
padding-bottom: 0.25em;
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
#container {
|
|
|
23 |
width: 400px;
|
|
|
24 |
height: 200px;
|
|
|
25 |
border: 4px double #333;
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
#grid {
|
|
|
29 |
border: 1px solid #333;
|
|
|
30 |
}
|
|
|
31 |
</style>
|
|
|
32 |
<script type="text/javascript" src="../../../dojo/dojo.js"
|
|
|
33 |
djConfig="isDebug:false, parseOnLoad: true"></script>
|
|
|
34 |
<script type="text/javascript">
|
|
|
35 |
dojo.require("dojox.grid.Grid");
|
|
|
36 |
dojo.require("dojox.grid._data.model");
|
|
|
37 |
dojo.require("dojo.parser");
|
|
|
38 |
</script>
|
|
|
39 |
<script type="text/javascript">
|
|
|
40 |
data = [
|
|
|
41 |
[ "normal", false, "new", 'But are not followed by two hexadecimal', 29.91, 10, false ],
|
|
|
42 |
[ "important", false, "new", 'Because a % sign always indicates', 9.33, -5, false ],
|
|
|
43 |
[ "important", false, "read", 'Signs can be selectively', 19.34, 0, true ],
|
|
|
44 |
[ "note", false, "read", 'However the reserved characters', 15.63, 0, true ],
|
|
|
45 |
[ "normal", false, "replied", 'It is therefore necessary', 24.22, 5.50, true ],
|
|
|
46 |
[ "important", false, "replied", 'To problems of corruption by', 9.12, -3, true ],
|
|
|
47 |
[ "note", false, "replied", 'Which would simply be awkward in', 12.15, -4, false ]
|
|
|
48 |
];
|
|
|
49 |
model = new dojox.grid.data.table(null, data);
|
|
|
50 |
|
|
|
51 |
// grid structure
|
|
|
52 |
// a grid view is a group of columns
|
|
|
53 |
// a special view providing selection feedback
|
|
|
54 |
var rowBar = {type: 'dojox.GridRowView', width: '20px'};
|
|
|
55 |
|
|
|
56 |
// a view without scrollbars
|
|
|
57 |
var leftView = {
|
|
|
58 |
noscroll: true,
|
|
|
59 |
cells: [[
|
|
|
60 |
{name: 'Column 0'},
|
|
|
61 |
{name: 'Column 1'}
|
|
|
62 |
]]};
|
|
|
63 |
|
|
|
64 |
var middleView = {
|
|
|
65 |
cells: [[
|
|
|
66 |
{name: 'Column 2'},
|
|
|
67 |
{name: 'Column 3'},
|
|
|
68 |
{name: 'Column 4'},
|
|
|
69 |
{name: 'Column 5'},
|
|
|
70 |
{name: 'Column 6'},
|
|
|
71 |
]]};
|
|
|
72 |
|
|
|
73 |
// a grid structure is an array of views.
|
|
|
74 |
var structure = [ rowBar, leftView, middleView];
|
|
|
75 |
|
|
|
76 |
// get can return data for each cell of the grid
|
|
|
77 |
function get(inRowIndex) {
|
|
|
78 |
return [this.index, inRowIndex].join(', ');
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
function resizeInfo() {
|
|
|
82 |
setTimeout(function() {
|
|
|
83 |
dojo.byId('gridWidth').value = grid.domNode.clientWidth;
|
|
|
84 |
dojo.byId('gridHeight').value = grid.domNode.clientHeight;
|
|
|
85 |
}, 1);
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
function resizeGrid() {
|
|
|
89 |
grid.autoHeight = false;
|
|
|
90 |
grid.autoWidth = false;
|
|
|
91 |
var
|
|
|
92 |
w = Number(dojo.byId('gridWidth').value),
|
|
|
93 |
h = Number(dojo.byId('gridHeight').value);
|
|
|
94 |
|
|
|
95 |
dojo.contentBox(grid.domNode, {w: w, h: h});
|
|
|
96 |
grid.update();
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
function fitWidth() {
|
|
|
100 |
grid.autoWidth = true;
|
|
|
101 |
grid.autoHeight = false;
|
|
|
102 |
grid.update();
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
function fitHeight() {
|
|
|
106 |
grid.autoWidth = false;
|
|
|
107 |
grid.autoHeight = true;
|
|
|
108 |
grid.update();
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
function fitBoth() {
|
|
|
112 |
grid.autoWidth = true;
|
|
|
113 |
grid.autoHeight = true;
|
|
|
114 |
grid.update();
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
function sizeDefault() {
|
|
|
118 |
grid.autoWidth = false;
|
|
|
119 |
grid.autoHeight = false;
|
|
|
120 |
grid.domNode.style.width = '';
|
|
|
121 |
grid.domNode.style.height = 0;
|
|
|
122 |
grid.update();
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
dojo.addOnLoad(function() {
|
|
|
126 |
window["grid"] = dijit.byId("grid");
|
|
|
127 |
dojo.byId('gridWidth').value = 500;
|
|
|
128 |
dojo.byId('gridHeight').value = 200;
|
|
|
129 |
dojo.connect(grid, 'update', resizeInfo);
|
|
|
130 |
resizeGrid();
|
|
|
131 |
window["grid1"] = dijit.byId("grid1");
|
|
|
132 |
});
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
</script>
|
|
|
136 |
</head>
|
|
|
137 |
<body class="tundra">
|
|
|
138 |
<div class="heading">dojox.Grid Sizing Test</div>
|
|
|
139 |
Grid width: <input id="gridWidth" type="text">
|
|
|
140 |
and height: <input id="gridHeight" type="text">
|
|
|
141 |
<button onclick="resizeGrid()">Resize Grid</button><br><br>
|
|
|
142 |
<button onclick="fitWidth()">Fit Data Width</button>
|
|
|
143 |
<button onclick="fitHeight()">Fit Data Height</button>
|
|
|
144 |
<button onclick="fitBoth()">Fit Data Width & Height</button>
|
|
|
145 |
<button onclick="sizeDefault()">DefaultSize</button><br><br>
|
|
|
146 |
<div id="grid" dojoType="dojox.Grid" model="model" structure="structure" elasticView="2"></div>
|
|
|
147 |
|
|
|
148 |
<p>Grid fits to a sized container by default:</p>
|
|
|
149 |
<div id="container">
|
|
|
150 |
<div id="grid1" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="10" elasticView="2"></div>
|
|
|
151 |
</div>
|
|
|
152 |
|
|
|
153 |
</body>
|
|
|
154 |
</html>
|