diff options
Diffstat (limited to 'includes/js/dojox/grid/tests/test_expand.html')
-rw-r--r-- | includes/js/dojox/grid/tests/test_expand.html | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/includes/js/dojox/grid/tests/test_expand.html b/includes/js/dojox/grid/tests/test_expand.html new file mode 100644 index 0000000..220c2a8 --- /dev/null +++ b/includes/js/dojox/grid/tests/test_expand.html @@ -0,0 +1,107 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> + <title>Test dojox.Grid Expand Rows</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> + <style type="text/css"> + @import "../_grid/Grid.css"; + body { + font-size: 0.9em; + font-family: Geneva, Arial, Helvetica, sans-serif; + } + .heading { + font-weight: bold; + padding-bottom: 0.25em; + } + + .bigHello { + height: 110px; + line-height: 110px; + text-align: center; + font-weight: bold; + font-size: 30px; + } + + #grid { + border: 1px solid #333; + height: 30em; + } + </style> + <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dojox.grid.Grid"); + dojo.require("dojo.parser"); + </script> + <script type="text/javascript"> + // grid structure + // a grid view is a group of columns + + // a special view providing selection feedback + var rowBar = {type: 'dojox.GridRowView', width: '20px' }; + + // inRow is an array of subRows. we hide the summary subRow except for every nth row + function onBeforeRow(inDataIndex, inRow) { + inRow[1].hidden = (!this.grid || !this.grid.expandedRows || !this.grid.expandedRows[inDataIndex]); + } + + var view = { + onBeforeRow: onBeforeRow, + cells: [ + [ + { name: 'Whatever', width: 4.5, get: getCheck, styles: 'text-align: center;' }, + {name: 'Column 0'}, + {name: 'Column 1'}, + {name: 'Column 2'}, + {name: 'Column 3'}, + {name: 'Column 4'} + ], + [ { name: 'Detail', colSpan: 6, get: getDetail } ] + ] + }; + + // a grid structure is an array of views. + var structure = [ rowBar, view ]; + + // get can return data for each cell of the grid + function get(inRowIndex) { + return [this.index, inRowIndex].join(', '); + } + + function getDetail(inRowIndex) { + if (this.grid.expandedRows[inRowIndex]) { + var n = (inRowIndex % 2); + switch (n) { + case 0: + return 'Hello World!'; + default: + return '<div class="bigHello">Hello World!</div>'; + } + } else + return ''; + } + + function toggle(inIndex, inShow) { + grid.expandedRows[inIndex] = inShow; + grid.updateRow(inIndex); + } + + function getCheck(inRowIndex) { + if (!this.grid.expandedRows) + this.grid.expandedRows = [ ]; + var image = (this.grid.expandedRows[inRowIndex] ? 'open.gif' : 'closed.gif'); + var show = (this.grid.expandedRows[inRowIndex] ? 'false' : 'true') + return '<img src="images/' + image + '" onclick="toggle(' + inRowIndex + ', ' + show + ')" height="11" width="11">'; + } + + dojo.addOnLoad(function() { + window["grid"] = dijit.byId("grid"); + }); +</script> +</head> +<body> +<div class="heading">dojox.Grid Expand Row Example</div> + +<div id="grid" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="100000" autoWidth="true"></div> + +</body> +</html> |