94c65b7a413482df02364566fcf60ab03e3c5d22.svn-base 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>Dojox HtmlDataStore Widget</title>
  5. <style>
  6. @import "../../../../dijit/themes/tundra/tundra.css";
  7. @import "../../../../dojo/resources/dojo.css";
  8. @import "../../../../dijit/tests/css/dijitTests.css";
  9. </style>
  10. <script type="text/javascript">
  11. djConfig = {
  12. isDebug: true,
  13. parseOnLoad: true
  14. };
  15. </script>
  16. <script type="text/javascript" src="../../../../dojo/dojo.js"></script>
  17. <!--
  18. <script language="JavaScript" type="text/javascript">
  19. dojo.require("doh.runner");
  20. function registerTests() {
  21. doh.register("t",
  22. [
  23. function testTableLoaded(t){
  24. t.assertTrue(tableStore !== null);
  25. t.assertTrue(tableStore !== undefined);
  26. }
  27. ]
  28. );
  29. doh.run();
  30. };
  31. dojo.addOnLoad(registerTests);
  32. </script>
  33. -->
  34. <script language="JavaScript" type="text/javascript">
  35. dojo.require("dojo.parser");
  36. dojo.require("dojox.data.HtmlTableStore");
  37. dojo.require("dijit.Tree");
  38. function init() {
  39. var table = tableStore;
  40. function testComplete(items, request){
  41. console.debug("Completed!");
  42. var attributes = null;
  43. for(var i = 0; i < items.length; i++){
  44. attributes = table.getAttributes(items[i]);
  45. for(var j=0; j < attributes.length; j++){
  46. console.debug("attribute: [" + attributes[j] + "] have value: " + table.getValue(items[i], attributes[j]));
  47. }
  48. }
  49. }
  50. table.fetch({query:{X:1}, onComplete: testComplete});
  51. table.fetch({query:{X:2}, onComplete: testComplete});
  52. table.fetch({query:{X:3}, onComplete: testComplete});
  53. table.fetch({query:{X:4}, onComplete: testComplete});
  54. table.fetch({query:{X:5}, onComplete: testComplete}); // Should be empty
  55. }
  56. dojo.addOnLoad(init);
  57. </script>
  58. </head>
  59. <body class="tundra">
  60. <h1>Dojox HtmlDataStore Widget</h1>
  61. <hr/>
  62. <br/>
  63. <br/>
  64. <!-- Instantiate the HtmlTableStore and bind it to global name tableStore -->
  65. <div dojoType="dojox.data.HtmlTableStore" tableId="tableExample" jsId="tableStore"></div>
  66. <!-- The table to link into with the HtmlTableStore-->
  67. <table id="tableExample">
  68. <thead>
  69. <tr>
  70. <th>X</th>
  71. <th>Y</th>
  72. <th>A</th>
  73. <th>B</th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. <tr id="test">
  78. <td>2</td>
  79. <td>3</td>
  80. <td></td>
  81. <td>8</td>
  82. </tr>
  83. <tr>
  84. <td>1</td>
  85. <td>3</td>
  86. <td>5</td>
  87. <td>7</td>
  88. </tr>
  89. <tr>
  90. <td>4</td>
  91. <td>9</td>
  92. <td>22</td>
  93. <td>777</td>
  94. </tr>
  95. <tr>
  96. <td>3231</td>
  97. <td>3</td>
  98. <td>535</td>
  99. <td>747</td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. <br/>
  104. <br/>
  105. <blockquote>
  106. <b>Table Rows: <br/><i>(Just to show that the tree can determine that the tableStore works like a store).<br/>Should have three branches, where the row had attr Y value of 3.</i></b>
  107. <div dojoType="dijit.Tree" id="tree" store="tableStore" query="{Y:3}" label="Test tree"></div>
  108. </blockquote>
  109. </body>
  110. </html>