You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.0 KiB
142 lines
4.0 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
|
"http://www.w3.org/TR/html4/loose.dtd"> |
|
<html> |
|
<head> |
|
<title>dojox.grid.Grid Sizing Example</title> |
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
|
<style type="text/css"> |
|
@import "../../../dojo/resources/dojo.css"; |
|
@import "../resources/Grid.css"; |
|
@import "../resources/tundraGrid.css"; |
|
|
|
.heading { |
|
font-weight: bold; |
|
padding-bottom: 0.25em; |
|
} |
|
|
|
#container { |
|
width: 400px; |
|
height: 200px; |
|
border: 4px double #333; |
|
} |
|
|
|
#grid { |
|
border: 1px solid #333; |
|
} |
|
</style> |
|
<script type="text/javascript" src="../../../dojo/dojo.js" |
|
data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
|
<script type="text/javascript"> |
|
dojo.require("dijit.dijit"); |
|
dojo.require("dojox.grid.DataGrid"); |
|
dojo.require("dojo.data.ItemFileWriteStore"); |
|
dojo.require("dojo.parser"); |
|
</script> |
|
<script type="text/javascript" src="support/test_data.js"></script> |
|
<script type="text/javascript"> |
|
var structure = [ |
|
{ |
|
noscroll: false, |
|
cells: [ |
|
{name: 'Column 1', field: 'col1'}, |
|
{name: 'Column 2', field: 'col2'} |
|
] |
|
}, |
|
[ |
|
{name: 'Column 3', field: 'col3'}, |
|
{name: 'Column 4', field: 'col4'}, |
|
{name: 'Column 5', field: 'col5'}, |
|
{name: 'Column 6', field: 'col6'}, |
|
{name: 'Column 7', field: 'col7'} |
|
] |
|
]; |
|
|
|
// get can return data for each cell of the grid |
|
function get(inRowIndex) { |
|
return [this.index, inRowIndex].join(', '); |
|
} |
|
|
|
function resizeInfo() { |
|
setTimeout(function() { |
|
dojo.byId('gridWidth').value = grid.domNode.clientWidth; |
|
dojo.byId('gridHeight').value = grid.domNode.clientHeight; |
|
}, 1); |
|
} |
|
|
|
function resizeGrid() { |
|
grid.set('autoHeight', false); |
|
grid.set('autoWidth', false); |
|
var |
|
w = Number(dojo.byId('gridWidth').value), |
|
h = Number(dojo.byId('gridHeight').value); |
|
|
|
dojo.contentBox(grid.domNode, {w: w, h: h}); |
|
grid.update(); |
|
} |
|
|
|
function fitWidth() { |
|
grid.set('autoHeight', false); |
|
grid.set('autoWidth', true); |
|
grid.update(); |
|
} |
|
|
|
function fitHeight() { |
|
grid.set('autoHeight', true); |
|
grid.set('autoWidth', false); |
|
grid.update(); |
|
} |
|
|
|
function fitBoth() { |
|
grid.set('autoHeight', true); |
|
grid.set('autoWidth', true); |
|
grid.update(); |
|
} |
|
|
|
function sizeDefault() { |
|
grid.set('autoHeight', false); |
|
grid.set('autoWidth', false); |
|
grid.domNode.style.width = ''; |
|
grid.domNode.style.height = 0; |
|
grid.update(); |
|
} |
|
|
|
dojo.addOnLoad(function() { |
|
dojo.byId('gridWidth').value = 500; |
|
dojo.byId('gridHeight').value = 200; |
|
dojo.connect(grid, 'update', resizeInfo); |
|
resizeGrid(); |
|
}); |
|
</script> |
|
</head> |
|
<body class="tundra"> |
|
<div class="heading">dojox.grid.Grid Sizing Test</div> |
|
Grid width: <input id="gridWidth" type="text"> |
|
and height: <input id="gridHeight" type="text"> |
|
<button onclick="resizeGrid()">Resize Grid</button><br><br> |
|
<button onclick="fitWidth()">Fit Data Width</button> |
|
<button onclick="fitHeight()">Fit Data Height</button> |
|
<button onclick="fitBoth()">Fit Data Width & Height</button> |
|
<button onclick="sizeDefault()">DefaultSize</button><br><br> |
|
<div id="grid" data-dojo-id="grid" dojoType="dojox.grid.DataGrid" |
|
autoWidth="true" autoHeight="true" store="test_store" |
|
structure="structure" elasticView="2"></div> |
|
|
|
<p>Grid fits to a sized container by default:</p> |
|
<div id="container"> |
|
<div id="grid1" data-dojo-id="grid1" dojoType="dojox.grid._Grid" |
|
get="get" structure="structure" rowCount="10" elasticView="2"></div> |
|
</div> |
|
|
|
<p> Grid is essentially hidden (height of zero) when parent container is unsized |
|
(nothing, including the header, should be displayed):</p> |
|
<div id="unsizedContainer"> |
|
<div id="grid2" dojoType="dojox.grid._Grid" |
|
get="get" structure="structure" rowCount="10" elasticView="2"></div> |
|
</div> |
|
|
|
<p> Grid is autoHeight and autoWidth via markup</p> |
|
<div id="grid3" dojoType="dojox.grid._Grid" |
|
autoWidth="true" autoHeight="true" get="get" |
|
structure="structure" rowCount="10" elasticView="2"></div> |
|
</body> |
|
</html>
|
|
|