This is a migrated thread and some comments may be shown as answers.

Is it possible to drag and drop from a grid view to a scheduler then the appointment will be set automatically??

12 Answers 174 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Anoop
Top achievements
Rank 1
Anoop asked on 19 Apr 2011, 12:33 PM

Is it possible to drag and drop from a grid view to a scheduler then the appointment will be set and save automatically??

 

For example in the same window I have grid view and   scheduler

If there is a person call John in grid view that has a kind of an appointment, so when I drag that person from grid to scheduler the appointment should be automatically added to the selected place and time.


For more detail check the attached picture



Thanks in advance

12 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 19 Apr 2011, 12:42 PM
Hello Anoop,

Yes, you can do this. Please open up the Telerik Winforms demons that are on your PC and navigate to the Scheduler demos, and then drag&drop. You will see that this scenario is covered in the demos. I.e there is a demo of a drag drop from RadGridView to RadScheduler to create an appointment.
Hope that helps
Richard
0
Anoop
Top achievements
Rank 1
answered on 20 Apr 2011, 12:08 PM

Thanks a lot Richard,,

I tried this small example since I do not know how to use or run demos codes its using some extra classes and such a thing witch is not working well with me.

But I could not understand how to declare the drag object

 

Dim dragObject As DragObject = TryCast(e.Data.GetData(GetType(DragObject)), DragObject)

 

This object is giving me an error that it can not be declare

 

If you have any idea please letme know since it might need to add some reference or such a thing

the above line give me an errror and this two line of code too coz it is related to the above one as I believe  

 

 
Me
.mouseDownPosition = point.Empty

 

 

 

Me.isDragging = False

 



ublic Class RadForm1
  
  
    Private Sub radScheduler1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
        Dim point As Point = Me.radScheduler1.PointToClient(New Point(e.X, e.Y))
  
        Dim table As DayViewAppointmentsTable = (TryCast(Me.radScheduler1.SchedulerElement.ViewElement, SchedulerDayViewElement)).DataAreaElement.Table
        Dim schedulerCell As SchedulerCellElement = SchedulerUIHelper.GetCellAtPoint(point, table.Children)
        If schedulerCell IsNot Nothing Then
  
            Dim dragObject As DragObject = TryCast(e.Data.GetData(GetType(DragObject)), DragObject)
            If dragObject IsNot Nothing Then
                Me.RadScheduler1.Appointments.BeginUpdate()
                Dim appointment As Appointment = CreateAppointment(schedulerCell.Date, dragObject)
                Me.RadScheduler1.Appointments.Add(appointment)
                Me.RadScheduler1.Appointments.EndUpdate()
            End If
        End If
  
        Me.mouseDownPosition = point.Empty
        Me.isDragging = False
    End Sub
    Private Function CreateAppointment(ByVal currentDate As Date, ByVal dragObject As DragObject) As Appointment
        Dim appointment As New Appointment()
        Dim startDate As Date = currentDate
        Dim endDate As Date = currentDate.AddHours(1)
        Select Case dragObject.Status
            Case AppointmentFields.Summary
                appointment.Summary = TryCast(dragObject.Values(dragObject.Status), String)
            Case AppointmentFields.Row
                appointment.Summary = TryCast(dragObject.Values(AppointmentFields.Summary), String)
                appointment.Description = TryCast(dragObject.Values(AppointmentFields.Description), String)
                appointment.BackgroundId = CInt(Fix(dragObject.Values(AppointmentFields.Background)))
                appointment.StatusId = CInt(Fix(dragObject.Values(AppointmentFields.Status)))
                appointment.Location = TryCast(dragObject.Values(AppointmentFields.Location), String)
  
                startDate = CDate(dragObject.Values(AppointmentFields.Start))
                endDate = CDate(dragObject.Values(AppointmentFields.End))
  
                Dim range As TimeSpan = endDate.Subtract(startDate)
                endDate = currentDate.Add(range)
                startDate = currentDate
  
        End Select
        appointment.Start = startDate
        appointment.End = endDate
        Return appointment
    End Function
  
    Private Sub RadScheduler1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadScheduler1.Click
  
    End Sub
    Private Enum AppointmentFields
        Row
        Summary
        Location
        Description
        Start
        [End]
        Background
        Status
    End Enum
End Class
0
Richard Slade
Top achievements
Rank 2
answered on 20 Apr 2011, 12:15 PM
Hello Anoop,

It's really easy to get to the examples and you will find everything that you need in there. Just browse to (for exmaple)
 C:\Program Files (x86)\Telerik\RadControls for WinForms Q1 2011\Examples\QuickStart and then open the solution which is right for your environment. E.g. ExamplesCSVS2010.sln

Hope that helps
Richard
0
Anoop
Top achievements
Rank 1
answered on 20 Apr 2011, 12:34 PM

How about the example I just post >>do you have any idea,,

Dim dragObject As DragObject = TryCast(e.Data.GetData(GetType(DragObject)), DragObject)

 

For the example I can run the demo and see the code, but my problem was with the code itself it’s giving me an error when I use it after creating a new project

0
Richard Slade
Top achievements
Rank 2
answered on 20 Apr 2011, 01:35 PM
Hi Anoop,

I'm having trouble understanding the issue that you're having. Have you tried the demo example?
Richard
0
Anoop
Top achievements
Rank 1
answered on 21 Apr 2011, 05:57 AM
the whole example is here(Link)

but dragobject can not be declare I don’t know what is the reason behind that

 

I need to understand how this object work

0
Richard Slade
Top achievements
Rank 2
answered on 21 Apr 2011, 09:34 AM
Hello Anoop,

The DragObject is an object that you write yourself that holds the information that you wish to drag. For exmaple, in the demo app, the DragObject is written as follows:

Private Class DragObject            
  
Private status_Renamed As AppointmentFields            
  
Private values_Renamed As Dictionary(Of AppointmentFields, Object) = New Dictionary(Of AppointmentFields, Object)()      
  
Public Property Status() As AppointmentFields                
    Get                    
        Return Me.status_Renamed                
    End Get                
        Set(ByVal value As AppointmentFields)                    
        Me.status_Renamed = value                
    End Set            
End Property            
  
Public ReadOnly Property Values() As Dictionary(Of AppointmentFields, Object)                
    Get                    
        Return Me.values_Renamed                
    End Get            
End Property        
  
End Class

I hope that helps but do let me know if you need further help
Richard
0
Ivan Todorov
Telerik team
answered on 22 Apr 2011, 10:36 AM
Hi Anoop,

Please remember to mark Richard's reply as answer if you find it helpful. Write back if you have additional questions.

Best wishes,
Ivan Todorov
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
0
Anoop
Top achievements
Rank 1
answered on 24 Apr 2011, 05:52 AM
Thanks a lot
how about this two line of code,,
is there is any reference need to be added?

Me.mouseDownPosition = point.Empty
        Me.isDragging = False
0
Anoop
Top achievements
Rank 1
answered on 25 Apr 2011, 10:29 AM

Can you please let me know how drag and drop work in simple example using scheduler and grid view?



thanks in advance
0
Richard Slade
Top achievements
Rank 2
answered on 26 Apr 2011, 09:19 AM
Hello Anoop,

Aside from the demos that you have already seen on your pc, please also take a look at this forum post which you may find helpful.
Regards,
Richard
0
Ivan Todorov
Telerik team
answered on 27 Apr 2011, 01:41 PM
Hi Anoop,

Have you managed to get this case working?

Feel free to write if you need further help.

Best wishes,
Ivan Todorov
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
Tags
Scheduler and Reminder
Asked by
Anoop
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Anoop
Top achievements
Rank 1
Ivan Todorov
Telerik team
Share this question
or