getting element position after drop

6 posts, 0 answers
  1. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 28 Dec 2016 Link to this post

    I need the element start and end time and the target resource after dragging it to a new position.

    Your examaple: http://demos.telerik.com/kendo-ui/scheduler/restriction works quite well, but only if using the "moveEnd" event handler .

    It seems that when registering kendoDropTargetArea, its "drop" event handler overwrites the "moveEnd" event handler of the scheduler.

    The problem is that the object "e" as recieved by the drop doesnt have start, end and resources.

    example:

    scheduler.view().content.kendoDropTargetArea({

            filter: ".k-scheduler-table td, .k-event",
            drop: function(e){

               // get start, end and resource

            }
    });

    $("#scheduler").kendoScheduler({

    ..

            moveEnd: function(e){

                // never gets here

            }

    });

     

     

     

  2. Anton
    Admin
    Anton avatar
    81 posts

    Posted 29 Dec 2016 Link to this post

    Hello Venelin,

    You could try the followoing approach:

    drop: function(e){
        //get start, end and resource
        var offset = $(e.dropTarget).offset();
        var slot = scheduler.slotByPosition(offset.left, offset.top);
     
        var startDate = slot.startDate;
        var endDate slot.endDate;
     }

    dojo example

    Regards,
    Anton
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 29 Dec 2016 in reply to Anton Link to this post

    That returns not the element start and end dates, but the slot ones.

    I already red in this thread http://www.telerik.com/forums/drag-drop-external-item-onto-scheduler that "I'm afraid this is not supported out of the box."

    So it seems i need to calculate that alone playing with the relative position of the selected element and the dropTarget

  4. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 29 Dec 2016 Link to this post

    I managed to create a sample solution with very slight deviation

    // get the view scaling values
    var tick = scheduler.view().options.majorTick;
    var columnWidth = scheduler.view().options.columnWidth;
    var widthTickFactor = tick / columnWidth; // represents how many minutes fit in one pixel
                   
    // get the selected element position /_schedulerDraggedElementUID is set on drag start/
    var selectedOffset = $( "div[data-uid='" + _schedulerDraggedElementUID + "']" ).offset()
     
    // get the drop position
    var dropOffset = $(e.target).offset();
                   
    // calc new start time /el.ui.start is the previous start time taken from the scheduler datasource/
    var offDiff = selectedOffset.left - dropOffset.left;
    var timeDiff = offDiff * widthTickFactor;
    var newStartTime = moment(el.ui.start).subtract(timeDiff,"minutes").format("YYYY-MM-DD HH:mm:ss")

     

    That i guess would only work, because dragging the element doesnt scroll the scheduler view.

    Is it actually possible to make the view scrollable while dragging the element?

  5. Anton
    Admin
    Anton avatar
    81 posts

    Posted 30 Dec 2016 Link to this post

    Hello Venelin,

    It seems I misunderstood what you have meant. Indeed this is a custom scenario and as mentioned in the forum post it is not supported out of the box. The view is actually scrollable if you use the scroll while dragging the event.

    Regards,
    Anton
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Venelin
    Venelin avatar
    14 posts
    Member since:
    Nov 2016

    Posted 30 Dec 2016 Link to this post

    Thank you
Back to Top