Opened 7 years ago

Closed 6 years ago

#15661 closed feature (worksforme)

Tree: ObjectStoreModel support for drop between

Reported by: bill Owned by: bill
Priority: high Milestone: 2.0
Component: Dijit Version: 1.7.3
Keywords: Cc:
Blocked By: #15660 Blocking:

Description (last modified by bill)

See also #15660. ObjectStoreModel needs updates to support betweenThreshold.

Here's some workaround code from Anthony Erwin (IBM, CCLA) that can be used as a starting point:

/*
 * Subclassing  ObjectStoreModel so we can support dnd  and other desired operations (while maintaining order) in
 * the preview tree.
 */
var  CustomObjectStoreModel = declare(ObjectStoreModel, {
        newItem: function ( /* dijit /tree/dndSource.__Item */  args, /*Item*/  parent, /* int ?*/  insertIndex, /*Item*/  before){
                 //Call superclass
                 this .inherited(arguments);
        
                 //Add hack to notify tree that parent's children have changed (so ordering can be maintained)
                 this ._parentChildrenChanged(parent);
        },
        
        pasteItem: function ( /*Item*/  childItem, /*Item*/  oldParentItem, /*Item*/  newParentItem,
                         /*Boolean*/  bCopy, /* int ?*/  insertIndex, /*Item*/  before){
                 //Call superclass
                 this .inherited(arguments);
                
                 //Add hack to notify tree that new parent's children have changed (so ordering can be maintained)
                 if  (newParentItem && (oldParentItem != newParentItem)) {
                         this ._parentChildrenChanged(newParentItem);
                } else  {
                         this ._parentChildrenChanged(oldParentItem);
                }
        },
        
        _parentChildrenChanged: function (parent) {
                 delete   this .childrenCache[ this .getIdentity(parent)];
                 var  onComplete = function (children) {
                         this .onChildrenChange(parent, children);
                }.bind( this );
                 var  onError = function () {
                        console.error( "CustomObjectStoreModel._parentChildrenChanged: problem getting children for parent = "  + this .getIdentity(parent));
                };
                 this .getChildren(parent, onComplete, onError);
        },
        
         // NOT needed for dnd
        mayHaveChildren: function (item) {
                 return  !item.leaf;
        }
});

Change History (3)

comment:1 Changed 7 years ago by bill

Blocked By: 15660 added
Description: modified (diff)
Milestone: tbd2.0
Type: enhancementfeature

comment:2 Changed 6 years ago by bill

Priority: undecidedhigh

comment:3 Changed 6 years ago by bill

Resolution: worksforme
Status: newclosed

Looking at the code now, it seems like ObjectStoreModel supports drop-between, although it's impossible to test since dojo/store/Memory doesn't support the before or parent parameters (#15660). But I'm going to close this ticket for now.

Note: See TracTickets for help on using tickets.