Announcement

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

    reparenting after overloading folderDrop on treegrid

    I'm working with the treegrid and I need it to write back to my server (mine, not the smartclient server) any re-orgs done when the user drags nodes around the tree.

    When I specify the folderDrop function I can capture all the information I need but the dragged item no longer automatically moves.

    The only example I can find pertains to dataset bound treegrids, which this is not.

    I've tried just setting the parent id field to the new value but no dice.

    So how can I get it to reparent like it does BEFORE I override the event handler?

    #2
    reparenting

    I figured it out. Here it is for posterity:

    folderDrop: function (dragRecords, dropFolder, index, sourceWidget) {
    var record=unitTree.getSelectedRecord();
    console.log(record.SysId + " will now go to " + dropFolder.SysId);
    var newUnit=dropFolder.SysId;
    var newRecord=record;
    newRecord.ReportsTo=newUnit;
    unitTree.removeData(record);
    unitTree.data.addList([newRecord],dropFolder, index);
    }

    Basically I have a list of military units in a hierarchy and want to be able to shift them around. unitTree is the ID of the tree grid.

    In this case SysId is the unique ID for my nodes. Basically I delete the old record, then insert a copy with the updated information in the new location.

    The console.log line is just there to see the information I wanted. I use firebug for my javascript development and console.log is used by that tool. If you don't use firebug inside firefox, console.log will throw an error.

    Of course given I can log the info its no problem to create something to post back to my database with the node parent.

    If there's a better faster way, I'm all ears.

    Comment


      #3
      Call Super in folderDrop(), then you can delete all that code.

      Comment

      Working...
      X