4c3e7f916173097114ff035a16ef8aa77cdd2ed2.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 Change Structure Example</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. #grid {
  17. border: 1px solid #333;
  18. width: 48em;
  19. height: 30em;
  20. }
  21. #grid .dojoxGrid-cell {
  22. text-align: center;
  23. }
  24. </style>
  25. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
  26. <script type="text/javascript">
  27. dojo.require("dojox.grid.Grid");
  28. dojo.require("dojox.grid._data.model");
  29. dojo.require("dojo.parser");
  30. </script>
  31. <script type="text/javascript">
  32. // get can return data for a cell of the grid
  33. function get(inRowIndex) {
  34. return [this.index, inRowIndex].join(', ');
  35. }
  36. // grid structure
  37. // a grid view is a group of columns
  38. // a special view providing selection feedback
  39. var rowBar = {type: 'dojox.GridRowView', width: '20px' };
  40. // a view without scrollbars
  41. var view0 = {
  42. noscroll: true,
  43. cells: [[
  44. {name: 'Alpha', value: '<input name="" type="checkbox" value="0">'},
  45. {name: 'Beta', get: get, width: 4.5}
  46. ]]};
  47. var view1 = {
  48. cells: [[
  49. {name: 'Apple', value: '<button>Apple</button>'},
  50. {name: 'Banana', get: get},
  51. {name: 'Beans', value: 'Happy to be grid!'},
  52. {name: 'Kiwi', get: get},
  53. {name: 'Orange', value: '<img src="images/flatScreen.gif" height="48" width="48">'},
  54. {name: 'Pear', get: get},
  55. {name: 'Tomato', width: 20, value: '<input name="" type="file">'},
  56. ]]};
  57. var view2 = {
  58. noscroll: true,
  59. cells: [
  60. [
  61. {name: 'Alpha', value: '<input name="" type="checkbox" value="0">', rowSpan: 2},
  62. {name: 'Beta', get: get, width: 4.5}
  63. ], [
  64. {name: 'Gamma', get: get}
  65. ],
  66. [
  67. {name: 'Epsilon', value: '<button>Epsilon</button>', colSpan: 2}
  68. ]
  69. ]
  70. }
  71. var view3 = {
  72. cells: [
  73. [
  74. {name: 'Apple', value: '<button>Apple</button>', rowSpan: 3},
  75. {name: 'Banana', get: get, width: 20},
  76. {name: 'Kiwi', get: get, width: 20},
  77. {name: 'Pear', get: get, width: 20},
  78. ],
  79. [
  80. {name: 'Beans', value: 'Happy to be grid!'},
  81. {name: 'Orange', value: '<img src="images/flatScreen.gif" height="48" width="48">'},
  82. {name: 'Tomato', value: '<input name="" type="file">'}
  83. ], [
  84. {name: 'Zuchini', value: '<span style="letter-spacing: 10em;">wide</span>', colSpan: 3}
  85. ]
  86. ]};
  87. // a grid structure is an array of views.
  88. // By default the middle view will be 'elastic', sized to fit the remaining space left by other views
  89. // grid.elasticView can also be manually set
  90. var structure = [ rowBar, view0, view1 ];
  91. var structure2 = [ rowBar, view2, view3 ];
  92. var l2 = false;
  93. toggleStructure = function() {
  94. l2 = !l2;
  95. grid.scrollToRow(0);
  96. grid.setStructure(l2 ? structure2 : structure);
  97. }
  98. dojo.addOnLoad(function() {
  99. window["grid"] = dijit.byId("grid");
  100. });
  101. </script>
  102. </head>
  103. <body>
  104. <div class="heading">dojox.VirtualGrid Change Structure Example</div>
  105. <p>
  106. <button onclick="toggleStructure()">Change Structure</button>
  107. </p>
  108. <div id="grid" dojoType="dojox.VirtualGrid" structure="structure" rowCount="100000" elasticView="2"></div>
  109. </body>
  110. </html>