model.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. dojo.declare(
  7. "dijit.tree.model",
  8. null,
  9. {
  10. // summary:
  11. // Contract for any data provider object for the tree.
  12. // description:
  13. // Tree passes in values to the constructor to specify the callbacks.
  14. // "item" is typically a dojo.data.Item but it's just a black box so
  15. // it could be anything.
  16. //
  17. // This (like `dojo.data.api.Read`) is just documentation, and not meant to be used.
  18. destroy: function(){
  19. // summary:
  20. // Destroys this object, releasing connections to the store
  21. // tags:
  22. // extension
  23. },
  24. // =======================================================================
  25. // Methods for traversing hierarchy
  26. getRoot: function(onItem){
  27. // summary:
  28. // Calls onItem with the root item for the tree, possibly a fabricated item.
  29. // Throws exception on error.
  30. // tags:
  31. // extension
  32. },
  33. mayHaveChildren: function(/*dojo.data.Item*/ item){
  34. // summary:
  35. // Tells if an item has or may have children. Implementing logic here
  36. // avoids showing +/- expando icon for nodes that we know don't have children.
  37. // (For efficiency reasons we may not want to check if an element actually
  38. // has children until user clicks the expando node)
  39. // tags:
  40. // extension
  41. },
  42. getChildren: function(/*dojo.data.Item*/ parentItem, /*function(items)*/ onComplete){
  43. // summary:
  44. // Calls onComplete() with array of child items of given parent item, all loaded.
  45. // Throws exception on error.
  46. // tags:
  47. // extension
  48. },
  49. // =======================================================================
  50. // Inspecting items
  51. isItem: function(/* anything */ something){
  52. // summary:
  53. // Returns true if *something* is an item and came from this model instance.
  54. // Returns false if *something* is a literal, an item from another model instance,
  55. // or is any object other than an item.
  56. // tags:
  57. // extension
  58. },
  59. fetchItemByIdentity: function(/* object */ keywordArgs){
  60. // summary:
  61. // Given the identity of an item, this method returns the item that has
  62. // that identity through the onItem callback. Conforming implementations
  63. // should return null if there is no item with the given identity.
  64. // Implementations of fetchItemByIdentity() may sometimes return an item
  65. // from a local cache and may sometimes fetch an item from a remote server.
  66. // tags:
  67. // extension
  68. },
  69. getIdentity: function(/* item */ item){
  70. // summary:
  71. // Returns identity for an item
  72. // tags:
  73. // extension
  74. },
  75. getLabel: function(/*dojo.data.Item*/ item){
  76. // summary:
  77. // Get the label for an item
  78. // tags:
  79. // extension
  80. },
  81. // =======================================================================
  82. // Write interface
  83. newItem: function(/* dojo.dnd.Item */ args, /*Item*/ parent, /*int?*/ insertIndex){
  84. // summary:
  85. // Creates a new item. See `dojo.data.api.Write` for details on args.
  86. // tags:
  87. // extension
  88. },
  89. pasteItem: function(/*Item*/ childItem, /*Item*/ oldParentItem, /*Item*/ newParentItem, /*Boolean*/ bCopy){
  90. // summary:
  91. // Move or copy an item from one parent item to another.
  92. // Used in drag & drop.
  93. // If oldParentItem is specified and bCopy is false, childItem is removed from oldParentItem.
  94. // If newParentItem is specified, childItem is attached to newParentItem.
  95. // tags:
  96. // extension
  97. },
  98. // =======================================================================
  99. // Callbacks
  100. onChange: function(/*dojo.data.Item*/ item){
  101. // summary:
  102. // Callback whenever an item has changed, so that Tree
  103. // can update the label, icon, etc. Note that changes
  104. // to an item's children or parent(s) will trigger an
  105. // onChildrenChange() so you can ignore those changes here.
  106. // tags:
  107. // callback
  108. },
  109. onChildrenChange: function(/*dojo.data.Item*/ parent, /*dojo.data.Item[]*/ newChildrenList){
  110. // summary:
  111. // Callback to do notifications about new, updated, or deleted items.
  112. // tags:
  113. // callback
  114. }
  115. });