Drag and drop help

12 posts, 0 answers
  1. hardik
    hardik avatar
    57 posts
    Member since:
    Feb 2011

    Posted 26 Apr 2011 Link to this post

    Hi telerik,

    I am using custom drag and drop class. I want to cancel the drag and drop in week and month view.

     public override bool CanStartDrag(DragDropState state)
        {      
          Some condition to check view mode. and as per that i return true or false.
           return base.CanStartDrag(state);
        }

    But in this class how can I know the view mode?

    Thanks
    Hardik
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 28 Apr 2011 Link to this post

    Hello Hardik,

    In order to get the view definition you can do the following:
    - create an attached property in your drag-n-drop behaviour
    - bind this property to the view definition.

    In that way you will be able to get the view definition and use it in your class.

    Please let us know if that was helpful.

    Best wishes,
    Konstantina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. hardik
    hardik avatar
    57 posts
    Member since:
    Feb 2011

    Posted 20 May 2011 Link to this post

    Hi telerik,

    I want to restrict the user to drag the appointment which is of another resource. Like in day mode 10 resources are selected.

    Now resource1 appointment can't be drag to resource2.  For that I think one logic is that  while dragging the appointment at that time I stored the Id of that particular resource whose appointment I am dragging.

     And when drop event is called at that time any how I will find the resource Id where the appointment is dropped. And then compare these two resource ID. if they don't match I will cancel the drag.

    Bot the problem is how can I get the resource Id where I drop the appointment. Is there any property from where I can get the information of resource where I drop the appointment.

    Thanks
    Hardik
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 20 May 2011 Link to this post

    Hello hardik,

    The slot where the appointmes are going to be dropped can be accessed from the DragDropState.TargetAreas property. I would suggest checking this property in the CanDrop method.

    Kind regards,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. hardik
    hardik avatar
    57 posts
    Member since:
    Feb 2011

    Posted 23 May 2011 Link to this post

    Thanks for the reply.

    Sorry to say but I am not able to get the property as you defined in your answer.

    I have check it as per your answer.


    Thanks
    Hardik
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 25 May 2011 Link to this post

    I apologize for misleading you. I was referring the DestinationSlots property:
    override bool CanDrop(DragDropState state)
    {
        var slots = state.DestinationSlots;
        ...
    }

    Kind regards,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. hardik
    hardik avatar
    57 posts
    Member since:
    Feb 2011

    Posted 03 Jun 2011 Link to this post

    Hi telerik,

    I have tried as per your suggestion. But I am not able to cast DestinationSlots as per my requirement.

    See Attached Image. How can I get the resource from this?

    Thanks
    Hardik
  8. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 07 Jun 2011 Link to this post

    Hello hardik,

    The value of the DestinationSlots property is a collection, hence the exception. You could use this code:
    using System.Linq;
    ...
    IList<Slot> slots = state.DestinationSlots;
    IList<IResource> resources = slots.First().Resources.OfType<IResource>();
    ...

    All the best,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. hardik
    hardik avatar
    57 posts
    Member since:
    Feb 2011

    Posted 09 Jun 2011 Link to this post

    Thanks for reply.

    As i have try to do as per your suggestion. It gives error of type cast. Actually DestinationSlots are of IEnumerable type not of Ilist.

    I have done with IEnumerable and its working fine.

    Thanks
    Hardik
  10. palak
    palak avatar
    102 posts
    Member since:
    May 2011

    Posted 11 Jul 2011 Link to this post

    Hi hardik,

    I want to implement same kind of logic for same timeslots. i want to restrict appointments which are supposed to be dropped on timeslot where there are already appointments exist, can u pls elaborate how can i do that ? actually i am not able to find any such "CanDrop" method for scheduleview. I am using Q2 beta 2011.

    thanks & regards

  11. Pana
    Admin
    Pana avatar
    748 posts

    Posted 15 Jul 2011 Link to this post

    Hi,

    Please check the FirstLook of the RadScheduleView and more precisely the ConflictCheckingDragDropBehavior and how it is applied. In the example one can not drop appointments on taken slots.

    Regards,
    Pana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  12. palak
    palak avatar
    102 posts
    Member since:
    May 2011

    Posted 15 Jul 2011 Link to this post

    Hi Pana,

    Many thanks for pointing me out this link, how i missed it out just don't know.

    It works like a charm.

    regards,
    palak
Back to Top