Opened 12 years ago

Closed 12 years ago

#9683 closed enhancement (fixed)

Tree: pass source to itemCreator()

Reported by: bill Owned by: bill
Priority: high Milestone: 1.4
Component: Dijit Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:


When an item is dragged from an external source (like a simple list) onto the Tree, Tree creates a new item and adds it to the model.

The user-overridable itemCreator() method is used to create the attributes for this item, and it returns something like:

{ id: 123,  label: "my new item", foo: "bar"}

However, itemCreator() needs access to the drag item's source and/or the sourceItem, not just the dragged domNode, to have enough information to create this object.

Change History (3)

comment:1 Changed 12 years ago by bill

Owner: set to bill
Status: newassigned

comment:2 Changed 12 years ago by bill

Summary: Tree: pass sourceItem to itemCreator()Tree: pass source to itemCreator()

Turns out itemCreator() is called with the whole set of dragged nodes (not once for each node), so the argument can't be sourceItem (although it could be an array of sourceItems), but I'll just pass the source.

comment:3 Changed 12 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [19652]) Number of fixes (!strict) around Tree DnD:

  • When dragging from a Tree and dropping somewhere, source.getItem() should return a dojo.dnd.Item, not a DomNode? (fixes #7058)
    • Pass source to itemCreator() so that the function can see the type of the dragged nodes. Also fixed documentation of itemCreator(). (fixes #9683)
  • fix dragging a random (non TreeNode?) widget and dropping onto the tree. In this case Tree should not assume the dragged widget has a item, parentNode, etc. like TreeNode?'s do. (fixes #9550)
  • better documentation (fixes #9684)
  • make Tree drag source support forInSelectedItems(), like dojo.dnd.Source (fixes #9685)
  • Avoid memory leak on IE by using dojo.attr(node, "id", ...) rather than setting id on the node's JS object (not sure if this matters though since id is a standard attribute name, not an expando property). (refs #9614)

I wasn't sure what fields are best to set in the object returned from getItem(). For now it's just setting type == treeNode and data == the TreeNode? widget.

Note: See TracTickets for help on using tickets.