61fc4a43f2749ab2a2c143a8d97c26b9d51e3d6e.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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>Test dojox.Grid Expand Rows</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
  6. <style type="text/css">
  7. @import "../_grid/Grid.css";
  8. body {
  9. font-size: 0.9em;
  10. font-family: Geneva, Arial, Helvetica, sans-serif;
  11. }
  12. .heading {
  13. font-weight: bold;
  14. padding-bottom: 0.25em;
  15. }
  16. .bigHello {
  17. height: 110px;
  18. line-height: 110px;
  19. text-align: center;
  20. font-weight: bold;
  21. font-size: 30px;
  22. }
  23. #grid {
  24. border: 1px solid #333;
  25. height: 30em;
  26. }
  27. </style>
  28. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
  29. <script type="text/javascript">
  30. dojo.require("dojox.grid.Grid");
  31. dojo.require("dojox.grid._data.model");
  32. dojo.require("dojo.parser");
  33. </script>
  34. <script type="text/javascript">
  35. // grid structure
  36. // a grid view is a group of columns
  37. // a special view providing selection feedback
  38. var rowBar = {type: 'dojox.GridRowView', width: '20px' };
  39. // inRow is an array of subRows. we hide the summary subRow except for every nth row
  40. function onBeforeRow(inDataIndex, inRow) {
  41. inRow[1].hidden = (!this.grid || !this.grid.expandedRows || !this.grid.expandedRows[inDataIndex]);
  42. }
  43. var view = {
  44. onBeforeRow: onBeforeRow,
  45. cells: [
  46. [
  47. { name: 'Whatever', width: 4.5, get: getCheck, styles: 'text-align: center;' },
  48. {name: 'Column 0'},
  49. {name: 'Column 1'},
  50. {name: 'Column 2'},
  51. {name: 'Column 3'},
  52. {name: 'Column 4'}
  53. ],
  54. [ { name: 'Detail', colSpan: 6, get: getDetail } ]
  55. ]
  56. };
  57. // a grid structure is an array of views.
  58. var structure = [ rowBar, view ];
  59. // get can return data for each cell of the grid
  60. function get(inRowIndex) {
  61. return [this.index, inRowIndex].join(', ');
  62. }
  63. function getDetail(inRowIndex) {
  64. if (this.grid.expandedRows[inRowIndex]) {
  65. var n = (inRowIndex % 2);
  66. switch (n) {
  67. case 0:
  68. return 'Hello World!';
  69. default:
  70. return '<div class="bigHello">Hello World!</div>';
  71. }
  72. } else
  73. return '';
  74. }
  75. function toggle(inIndex, inShow) {
  76. grid.expandedRows[inIndex] = inShow;
  77. grid.updateRow(inIndex);
  78. }
  79. function getCheck(inRowIndex) {
  80. if (!this.grid.expandedRows)
  81. this.grid.expandedRows = [ ];
  82. var image = (this.grid.expandedRows[inRowIndex] ? 'open.gif' : 'closed.gif');
  83. var show = (this.grid.expandedRows[inRowIndex] ? 'false' : 'true')
  84. return '<img src="images/' + image + '" onclick="toggle(' + inRowIndex + ', ' + show + ')" height="11" width="11">';
  85. }
  86. dojo.addOnLoad(function() {
  87. window["grid"] = dijit.byId("grid");
  88. });
  89. </script>
  90. </head>
  91. <body>
  92. <div class="heading">dojox.Grid Expand Row Example</div>
  93. <div id="grid" dojoType="dojox.VirtualGrid" get="get" structure="structure" rowCount="100000" autoWidth="true"></div>
  94. </body>
  95. </html>