Announcement

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

    Timeline widget support for DnD

    Hi,

    We have a requirement to create a new CalendarEvent in a Timeline by DragAndDrop of a record from a different grid.
    An example would be when trying to create a Vehicle appointment user can drag a Vehicle record on to a specific spot on a Timeline representing a calendar at a Location/Warehouse.

    I tried a couple of different things:

    1. Timeline.addDropHandler fires correctly, but DropEvent has no information about external entity and Timeline.getDropValues() returns null (Timeline.getAddDropValues() is true)
    2. Timeline.addDropCompleteHandler is not firing at all in this case. I was hoping I can get DropCompleteEvent.getTransferredRecords to point to Records from external grid...

    Can't figure out any other way to do this...

    Thanks!

    Sarkis

    #2
    The context of dragging is global, since there can be only one drag at a time. So you want to look at EventHandler APIs such as getDragTarget().

    Comment


      #3
      I am having trouble with this in 2 areas:

      1. Timeline.getDragType or Timeline.getDragData return nothing. Timeline.getDragTarget returns Timeline itself. So that's not very useful.
      2. Even if we figure out how to get the data out of DnD - how do I know where on Timeline it got dropped?

      Thank you!

      Sarkis

      Comment


        #4
        Timeline is not the drag target, it's the drop target. Again, call the APIs *on EventHandler* to discover the drag target. You can then obtain the dragData via getDragData() on the dragTarget.

        EventHandler.getDropTarget() is also how you can discover which subwidget of the Timeline was dropped on.

        Comment


          #5
          Ok. I finally got it as far as Drag Target data - thank you.
          However, drop location is still a mystery. EventHandler does not have getDropTarget() in my build and when I processs Timeline.DropHandler both DropEvent.getSource and getFiringCanvas point to the same thing - this Timeline object.

          Thanks!

          Sarkis

          Comment


            #6
            Sorry, there is no EventHandler.getDropTarget() since the the drop target is the one receiving the events - so it's just the event source, as you've discovered, and should properly be the Timeline in this case. It's not clear what additional information you need.. coordinates of the drop are available via EventHandler.getX() getY(), so you may be looking for Timeline.getDateFromPoint(x,y) to try to figure out what to do with the dropped data?

            If you need more help, please be specific about the information you are trying to discover.

            Comment


              #7
              This helped a lot. Interestingly, if I pass in event.getX and getY into getDataFromPoint is does not work right - picks a wrong spot. But if I call getDataFromPoint with no params - it works fine. So it figures out X and Y correctly on its own.
              Thanks a lot for your help!

              Sarkis

              Comment


                #8
                FYI, the problem is that getDataFromPoint() expects Timeline-relative coordinates, and you are passing in global coordinates, so you would need to subtract timeline.getPageLeft() / getPageTop() to correct them. But as you say, you don't actually need to pass them anyway in this usage.

                Comment

                Working...
                X