748371b968f36570832a39802d67c80010882cb9.svn-base 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>dojox.Grid with Dojo.Data via binding</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
  7. <style type="text/css">
  8. @import "../_grid/tundraGrid.css";
  9. @import "../../../dojo/resources/dojo.css";
  10. @import "../../../dijit/themes/tundra/tundra.css";
  11. @import "../../../dijit/tests/css/dijitTests.css";
  12. #grid, #grid2, #grid3 {
  13. width: 65em;
  14. height: 25em;
  15. padding: 1px;
  16. }
  17. </style>
  18. <script type="text/javascript" src="../../../dojo/dojo.js"
  19. djConfig="isDebug: true, debugAtAllCosts: false, parseOnLoad: true"></script>
  20. <script type="text/javascript">
  21. dojo.require("dojox.grid.Grid");
  22. dojo.require("dojox.grid._data.editors");
  23. dojo.require("dojox.grid._data.model");
  24. dojo.require("dojox.data.CsvStore");
  25. dojo.require("dojo.data.ItemFileWriteStore");
  26. dojo.require("dojo.parser");
  27. </script>
  28. <script type="text/javascript">
  29. function getRow(inRowIndex){
  30. return ' ' + inRowIndex;
  31. }
  32. var iEditor = dojox.grid.editors.Input;
  33. var layoutMovies = [
  34. // view 0
  35. { type: 'dojox.GridRowView', width: '20px' },
  36. // view 1
  37. { cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
  38. // view 2
  39. { cells: [[
  40. { field: "Title", editor: iEditor, width: 'auto' },
  41. { field: "Year", editor: iEditor, width: 5 },
  42. { field: "Producer", editor: iEditor, width: 20 }
  43. ]]}
  44. ];
  45. var layoutCountries = [
  46. // view 0
  47. { type: 'dojox.GridRowView', width: '20px' },
  48. // view 1
  49. { cells: [[{ name: "Row", get: getRow, width: 5}]], noscroll: true},
  50. // view 2
  51. { cells: [[
  52. { field: "name", name: "Name", width: 'auto' },
  53. { field: "type", name: "Type", editor: iEditor, width: 'auto' },
  54. ]]}
  55. ];
  56. </script>
  57. </head>
  58. <body class="tundra">
  59. <h1>dojox.Grid using Dojo.Data stores via simple binding</h1>
  60. <!--
  61. <br>
  62. <span dojoType="dojox.data.CsvStore"
  63. jsId="csvStore" url="support/movies.csv">
  64. </span>
  65. <span dojoType="dojox.grid.data.DojoData"
  66. jsId="dataModel"
  67. store="csvStore"
  68. rowsPerPage="5"
  69. query="{ Title: '*' }"
  70. clientSort="true">
  71. </span>
  72. <div id="grid" dojoType="dojox.Grid" elasticView="2"
  73. model="dataModel" structure="layoutMovies">
  74. </div>
  75. -->
  76. <br>
  77. <h3>Update some of the types</h3>
  78. <button onclick="updateCountryTypes();">Go!</button>
  79. <script>
  80. function updateCountryTypes(){
  81. // get everything starting with "A"
  82. jsonStore.fetch({
  83. query: { name: "A*" },
  84. onComplete: function(items, result){
  85. // change 'em!
  86. dojo.forEach(items, function(item){
  87. jsonStore.setValue(item, "type", "thinger");
  88. // console.debug(item);
  89. });
  90. }
  91. });
  92. }
  93. </script>
  94. <span dojoType="dojo.data.ItemFileWriteStore"
  95. jsId="jsonStore" url="../../../dijit/tests/_data/countries.json">
  96. </span>
  97. <span dojoType="dojox.grid.data.DojoData"
  98. jsId="dataModel2"
  99. rowsPerPage="20"
  100. store="jsonStore"
  101. clientSort="true"
  102. query="{ name : '*' }">
  103. </span>
  104. <div id="grid2" dojoType="dojox.Grid" elasticView="2"
  105. model="dataModel2" structure="layoutCountries">
  106. </div>
  107. <div id="grid3" dojoType="dojox.Grid" elasticView="2"
  108. model="dataModel2" structure="layoutCountries">
  109. </div>
  110. </body>
  111. </html>