Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TreeGrid ignore setPreventDuplicates(false)

    I'm using TreeGrid (Move) from the show case with Copy instead of move.
    I'd like to allow the user to duplicate items in the tree and to do that I'm setting setDuplicateDragMessage(false) on the TreeGrid.
    I'm able to create duplicate using the arrow button that invokes grid2.transferSelectedData(grid1);
    but when I try to create a duplicate by dragging and dropping the warn message appear.

    Is there any way to control the behavior oor at least have the transferSelectedData and the drop function to behave in the same way ?

    Cheers,
    FraM

    #2
    I have the exact same problem

    Comment


      #3
      Same here.

      Using smartgwt 3.0 NIGHTLY-2012-04-07. By looking at where this warning actually comes from (in TreeGrid.js) there is an explicit check against moveList in drop-function before the FolderDropHandler gets fired.

      Code:
      ...
          // make sure that they're not trying to drag into parent containing child with same name.
          // NOTE: this particular check is postponed until drop() because it's not self-evident why
          // the widget won't accept drop, so we want to warn() the user
          
          for (var i = 0; i < moveList.length; i++) {
              
              var child = moveList[i];
      
              // NOTE: If dragging in from another tree - set dragDataAction to "copy" to test the
              // code below, otherwise you end up with 2 trees pointing at the same object
      
              // name collision: see if there's already a child under the newParent that has the same
              // name as the child we're trying to put under that parent
              var collision = (this.data.findChildNum(newParent, this.data.getName(child)) != -1);
      
              // this collision is not a problem if we're reordering under the same parent
              var legalReorder = dragWithinTree && this.canReorderRecords && 
                                  newParent == this.data.getParent(child);
              if (collision && !legalReorder) {
                  this.logInfo("already a child named: " + this.data.getName(child) + 
                               " under parent: " + this.data.getPath(newParent));
                  isc.warn(this.parentAlreadyContainsChildMessage);
                  return false;
              }            
          }
      ...
      And yes it does not honor preventDuplicates, the check is explicit. This seems like a bug ?

      --
      Marko

      Comment


        #4
        This check isn't related to preventDuplicates. You can't have two children of the same parent with the same TreeNode.name. You can however have two children with different names, but the same user-visible title if you want.

        Comment

        Working...
        X