Announcement

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

    How to drop data into a TreeGrid from Canvas based widget?

    I've got a custom graphical widget based on an isc_Canvas. I've implemented the documented drag and drop interface and, for example, add my own getDragData() to my widget. Dragging from my widget to ListGrids, DetailViewers and TileGrids works fine. However, when I try to drag and drop from my widget into a TreeGrid folder, it fails with exceptions in SmartClient code.

    Some pertinent details:

    1) It appears that I have to implement a version of getData in my widget since that is used in TreeGrid.drop() to tell whether or not the drag and drop is within the same tree. I did that, just returning null which, from the code, appears to be enough to convince the drop code that we aren't moving elements within the same tree. That gets me past the first exception I ran into.

    2) Having done that, I am now getting exceptions caused be the fact that cloneDragData() is returning null. This is not a documented function so I don't really know what to do get around this.

    3) I'm using SmartClient 7.0, Safari 5.0.3 browser.

    4) I looked in the LGPL code (7.0rc2_LGPL) but the cloneDragData function is not in there. It appears that it was added after 7.0rc2. Apparently the LGPL download on your site does not correspond to our licensed 7.0 release. Are you planning to make available an LGPL version of the actual released code?

    So, given this background, my question is, how does one enable drag and drop into a TreeGrid from a custom widget? I may have missed it but I can't see any documented functions related to drag and drop that would help me here. Is there something more I need to implement in order to get this working? As far as I can tell, there is some stuff going on which assumes the source of the drag data is a Tree or Grid of some sort.

    Thanks,
    Scott

    #2
    cloneDragData() is there in the LGPL source, look at DataBoundComponent.js and you'll find the underpinnings of the drag and drop data transfer system in generic form (not specific to ListGrid or TreeGrid).

    It does, however, look like cloneDragData() needs to call getDragData() instead of calling getSelection() instead. In the meantime, implementing your own cloneDragData (which should just return a copy of the data to be dragged, instead of the original data) is fine.

    Comment


      #3
      Originally posted by Isomorphic
      cloneDragData() is there in the LGPL source, look at DataBoundComponent.js and you'll find the underpinnings of the drag and drop data transfer system in generic form (not specific to ListGrid or TreeGrid).
      Which LGPL download are you looking at? I downloaded the 7.0rc2_LGPL version, which is the only one I see on your downloads page (before I posted). When I run a search though all the javascript files I don't find any references to cloneDragData(). A similar search through our 7.0 licensed version finds several. I don't see any other LGPL download for the 7.0 series (at least if I go to the downloads page on your site).
      Originally posted by Isomorphic
      It does, however, look like cloneDragData() needs to call getDragData() instead of calling getSelection() instead. In the meantime, implementing your own cloneDragData (which should just return a copy of the data to be dragged, instead of the original data) is fine.
      Thanks, that makes sense.

      Comment


        #4
        Ah - cloneDragData() did not exist in 7.0rc2 (LGPL or commercial). You're actually using something post-7.0rc2 (look at the date stamp to confirm), that's why you have it - it was introduced somewhere between 7.0 and 8.0. In the 8.0 sources, you can see it in DataBoundComponent.js.

        Comment


          #5
          Originally posted by Isomorphic
          Ah - cloneDragData() did not exist in 7.0rc2 (LGPL or commercial). You're actually using something post-7.0rc2 (look at the date stamp to confirm), that's why you have it - it was introduced somewhere between 7.0 and 8.0. In the 8.0 sources, you can see it in DataBoundComponent.js.
          Yep, I guess we are past 7.0rc2. Looking at the download page, there seems to be a bit of a mixture of downloads labeled 7.0rc2 and 7.0. However, going back in my records, we did download 7.0 Power Edition so I guess that explains it.

          Implementing cloneDragData seems to almost fix the problem. There are no more exceptions and a new folder node is created in the TreeGrid (as I expect). However, it doesn't seem to have a name attached to it. It could be I have a bug. But perhaps I just need to supply a little more information in the drag data I'm passing back from cloneDragData(). Is there something which TreeGrid is looking for in dragged data which might be different from the other widgets?

          Comment


            #6
            No special requirements - basically the data is going to be treated as an Array of TreeNodes. The absence of a name just suggests that the data lacks a property involved in deciding on the name (see TreeGrid.getNodeTitle).

            Comment


              #7
              Yes, it seems I forgot a particular field in the data returned from cloneDragData, which was used for the name...
              All seems to work now, thanks.
              Scott

              Comment

              Working...
              X