model.js 3.9 KB

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