a01bfdc2054058356c735b223f936de51b8050b4.svn-base 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!--
  2. This file is a simple loader for the Lazy Load demo of a Datastore. In this
  3. Example, a simple extension of ItemFileReadStore that can do rudimentary lazy-loading
  4. of items into the store is used to showcase how Datastores can hide how data
  5. is loaded from the widget. As long as the widget implements to the Dojo.data API
  6. spec, then it should be able to use most datastores as input sources for its
  7. values.
  8. -->
  9. <html>
  10. <head>
  11. <title>Demo of Lazy Loading Datastore</title>
  12. <style type="text/css">
  13. @import "../../../dijit/themes/tundra/tundra.css";
  14. @import "../../../dojo/resources/dojo.css";
  15. @import "../../../dijit/tests/css/dijitTests.css";
  16. </style>
  17. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true, usePlainJson: true"></script>
  18. <script type="text/javascript">
  19. dojo.require("dojo.parser");
  20. dojo.require("dojox.data.demos.stores.LazyLoadJSIStore");
  21. dojo.require("dijit.Tree");
  22. </script>
  23. </head>
  24. <body class="tundra">
  25. <h1>
  26. DEMO: Lazy Loading Datastore used by dijit.Tree
  27. </h1>
  28. <hr>
  29. <h3>
  30. Description:
  31. </h3>
  32. <p>
  33. This simple demo shows how the dijit.Tree widget can work with a Datastore that does lazy-loading of values into the tree.
  34. In this demo, the Datastore is an extension of ItemFileReadStore that overrides the <i>isItemLoaded()</i> and <i>loadItem()</i> functions of
  35. with ones that can detect 'stub' items and use the data in the stub item to load the real data for that item when it
  36. is required. In this demo, the real data is required when one of the tree nodes is expanded.
  37. </p>
  38. <p>
  39. The key thing to note is that all the lazy-loading logic (how to locate the data from the backend and so forth) is encapsulated
  40. into the store functions. The dijit.Tree widget only knows about and uses the dojo.data.Read API interfaces to call to the store to
  41. get items, test if child items are fully loaded or not, and to invoke the <i>loadItem()</i> function on items that are not yet fully
  42. loaded but have been requested to be expanded into view. It has no knowledge of how the store actually goes and gets the data.
  43. </p>
  44. <blockquote>
  45. <!--
  46. The store instance used by this demo.
  47. -->
  48. <div dojoType="dojox.data.demos.stores.LazyLoadJSIStore" jsId="continentStore"
  49. url="geography/root.json"></div>
  50. <!--
  51. Display the toplevel tree with items that have an attribute of 'type',
  52. with value of 'contintent'
  53. -->
  54. <b>Continents</b>
  55. <div dojoType="dijit.Tree" id=tree label="Continents" store="continentStore" query="{type:'continent'}"
  56. labelAttr="name" typeAttr="type"></div>
  57. </blockquote>
  58. </body>
  59. </html>