Resource from specific cell

8 posts, 0 answers
  1. Lighthouse Developer
    Lighthouse Developer avatar
    34 posts
    Member since:
    Feb 2010

    Posted 15 May 2010 Link to this post

    Hi,

    I  drag and drop items from a radlistbox into a resource grouped scheduler with Timeline as active viewtype.
    How I can get the resource id and the date from the cell where an item was dropped?
  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 18 May 2010 Link to this post

    Hi Lighthouse Developer,

    Thank you for contacting us.

    Please, review the following example (installed with RadControls for WinForms) on how to take the cell where the item is being dropped: Demos -> Scheduler ->D rag&Drop example. From the example, take the cell's View.GetResources()[0]. When you are in grouping mode this collection contains only one item for each group:
     
    private void radScheduler1_DragDrop(object sender, DragEventArgs e)
    {
        Point point = this.radScheduler1.PointToClient(new Point(e.X, e.Y));
     
        DayViewAppointmentsTable table = (this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement).DataAreaElement.Table;
        SchedulerCellElement schedulerCell = SchedulerUIHelper.GetCellAtPoint(point, table.Children);
     
        DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
        if (dragObject != null)
        {
            this.radScheduler1.Appointments.BeginUpdate();
            Appointment appointment = CreateAppointment(schedulerCell.Date, dragObject);
            appointment.ResourceId = schedulerCell.View.GetResources()[0].Id;
            this.radScheduler1.Appointments.Add(appointment);
            this.radScheduler1.Appointments.EndUpdate();
        }
    }
     
    I hope that this will help you. If you have other question do not hesitate to contact us.

    Best wishes,
    Dobry Zranchev
    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. UI for WinForms is Visual Studio 2017 Ready
  4. Lighthouse Developer
    Lighthouse Developer avatar
    34 posts
    Member since:
    Feb 2010

    Posted 20 May 2010 Link to this post

    Hi Dobry
     and thank you very much for your help.

    I cant get drag and drop to work in Timeline view.
    In scheduler's  DragDrop function this statement:
    DayViewAppointmentsTable table = (this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement).DataAreaElement.Table; 

    doesn't seem to be right.If I executed it in visual studio's immediate window I get this:
    "this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement' is null"

    I have created a sample project.If the active view is Day view,drag  n drop works as expected. In Timeline view it doesn't work. Can we use something else than SchedulerDayViewElement? I saw that when the scheduler is in Timeline View the radScheduler1.SchedulerElement.ViewElement is of type SchedulerTimelineViewElement.


  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 21 May 2010 Link to this post

    Hi Lighthouse Developer,

    Before getting to your question, we would like to request to please update your account with your name, surname and nick name. This will allow us to work with you better. Thank you for your understanding.

    Depending on the ActiveView, RadScheduler creates a different element which could be SchedulerDayViewElement, SchedulerMonthViewElement, SchedulerTimelineViewElement, or SchedulerMultiDayViewElement. When you have enabled the grouping mode, RadScheduler can create a SchedulerDayViewGroupedByResourceElement, SchedulerMonthViewGroupedByResourceElement or SchedulerTimelineViewGroupingByResourcesElement. When you implement a custom drag and drop functionality, you need to get the instance of the ViewElement and cast it to the proper element.

    In your scenario, if you implement a drag and drop and your ActiveView is Timline, you need to use the SchedulerTimelineViewElement. If you have resources and your ActiveView is Timeline, you need to use the SchedulerTimelineViewGroupingByResourcesElement. The last has a method called GetTimelineElements which will give you the collection of the TimelineViewElements which are part of the SchedulerTimelineViewGroupingByResourcesElement.

    If you have additional questions, we will be happy to help you.


    Best wishes,
    Boyko Markov
    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.
  6. Lighthouse Developer
    Lighthouse Developer avatar
    34 posts
    Member since:
    Feb 2010

    Posted 21 May 2010 Link to this post

    Thank you very much Boyko.

    Unfortunately I cant find the class SchedulerTimelineViewGroupingByResourcesElement. Is there a specific reference that I need to include?

    Thank you again

  7. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 24 May 2010 Link to this post

    Hello Lighthouse Developer,

    Thank you for writing back.

    Please excuse us for inconvenience - the type of the element is TimelineGroupingByResourcesElement rather than SchedulerTimelineViewGroupingByResourcesElement.

    If you have other questions feel free to contact us.

    Regards,
    Dobry Zranchev
    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.
  8. Aaron
    Aaron avatar
    12 posts
    Member since:
    Mar 2012

    Posted 26 Feb 2013 Link to this post

    I have a similar issue. I am in grouped day view and on this line I am getting an error

    DayViewAppointmentsTable table = (this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement).DataAreaElement.Table;

    I see that what I need to cast the ViewElement as in this case is a SchedulerDayViewGroupedByResourceElement. The problem is that the SchedulerDayViewGroupedByResourceElement has no DataAreaElement.Table to pull out.

    Where can I find the DayViewAppointmentsTable in the SchedulerDayViewGroupedByResourceElement?
  9. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 01 Mar 2013 Link to this post

    Hello Aaron,

    In this view SchedulerDayViewGroupedByResourceElement contains several SchedulerDayViewElement objects, each one specific for a different resource. You can get these elements by using the GetDayViewElements method. Consider the sample below:
    SchedulerDayViewGroupedByResourceElement  viewElement = radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement;
    foreach (SchedulerDayViewElement dayViewElement in viewElement.GetDayViewElements())
    {
        DayViewAppointmentsTable table = dayViewElement.DataAreaElement.Table;
        //...
    }

    I hope it helps.
     
    Regards,
    Jack
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

    Interested, but can’t attend? Register anyway and we’ll send you the recording.
Back to Top
UI for WinForms is Visual Studio 2017 Ready