123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <!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("dojox.grid._data.model");
- 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>
|