Drap and Drop from list box to scheduler

20 posts, 2 answers
  1. Gregg
    Gregg avatar
    8 posts
    Member since:
    Jun 2009

    Posted 13 Aug 2009 Link to this post

    Hello,
    Does anyone know if it is possible to drag an item from a list box and drop that item on the scheduler control and have it create an appointment based off of the itemsource in the payload?

    Much Thanks,

    Gregg
  2. Answer
    Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 17 Aug 2009 Link to this post

    Hi Gregg,

    Please, let us know if support thread #235061 sent to you last week works for you. It contains an example illustrating how the requested scenario could be achieved.

    Sincerely yours,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Gregg
    Gregg avatar
    8 posts
    Member since:
    Jun 2009

    Posted 17 Aug 2009 Link to this post

    It worked great! Thanks for the response. I did have one other question. Is it possible to implement this same functionality but have the list box be in it's own control and the schedule tool be in it's own control.

    Example:
    ctrlWorkOrderLists (this would be it's own control with code for other uses/purposes)
    ctrlScheduling (this would be it's own control with code for scheduling). This may contain the schedule control, some combo boxes, maybe radio buttons that can change out data or something in the schedule.

    It is cleaner and easier to manage when parts of the app are segmented like that. Adding everything to one xaml page gets muddled and hard to update or change.

    Gregg
  5. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 19 Aug 2009 Link to this post

    Hi ,

      Can you please send me the same sample. I am also working for the same requirement.
      Please send me the working sample.

    Regards
    Satish
  6. Answer
    Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 19 Aug 2009 Link to this post

    Hi satish,

    The example has just been described in this blog post. Also, here is the link to the example project included.

    Gregg,
    I think the same scenario can be achieved with a custom control with a Listbox inside it. The most important thing you will need to do is to set the RadDragAndDropManager.AllowDrag attached property to each of its items to inable them to drag. Besides, the RadDragAndDropManager.AllowDrop attached property must be set to each TimeSlotItem in the scheduler control. I suggest you to review the example in the above mentioned blog post, since it is a bit smarter.  

    Hope this helps. Should you need further support, get in touch with us.

    All the best,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  7. Gregg
    Gregg avatar
    8 posts
    Member since:
    Jun 2009

    Posted 19 Aug 2009 Link to this post

    Thanks! Great support as always!
  8. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 20 Aug 2009 Link to this post

    Hello,

     Extremely helpful.  I really appreciate including the sample solution as well.  Much appreciated!
     I am having onemore problem in the same. My Problem is like

     OnDropInfo method I am population childwindow. If user clicks on Accept button in childwindow. Then I have to Add Appointment in the perticular date. I can't able to do this. I am able to populate the window. After clicking on Accept button I can't able to Add the appointments.  Please find the code below.

    private void OnDropInfo(object sender, DragDropEventArgs e)  
            {  
     
                var sourceListBoxItem = e.Options.Source as System.Windows.Controls.ListBoxItem;  
                var timeSlotItem = e.Options.Destination as TimeSlotItem;  
                if (e.Options.Status == DragStatus.DropComplete && timeSlotItem != null)  
                {  
                      
                    String sSubject;  
                    sSubject = sourceListBoxItem.FindChildByType<TextBlock>().Text;  
                    DateTime oSchdStartDate;  
                    oSchdStartDate = DateTime.Parse(timeSlotItem.TimeSlot.Start.Date.ToShortDateString());  
                    DateTime oSchdEndDate;  
                    oSchdEndDate = DateTime.Parse(timeSlotItem.TimeSlot.End.Date.ToShortDateString());  
     
                    dlg_AddAppointments oWindow = new dlg_AddAppointments();  
                    oWindow.SetValues(sSubject, oSchdStartDate, oSchdEndDate);  
                    oWindow.Show();  
     
                      
                }  
            } 

     Can anybody please help me on this. It's very urgent for me.

    Thanks & Regards
    Satish

     

     

  9. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 21 Aug 2009 Link to this post

    Hi satish,

    I think that if you replace the OnDropInfo handler with the slightly modified one below:

    private void OnDropInfo(object sender, DragDropEventArgs e) 
        var sourceListBoxItem = e.Options.Source as System.Windows.Controls.ListBoxItem; 
        var timeSlotItem = e.Options.Destination as TimeSlotItem; 
        if (e.Options.Status == DragStatus.DropComplete && timeSlotItem != null
        { 
            DialogParameters dp = new DialogParameters(); 
     
            RadWindow.Confirm("Do you really want to add this item to scheduler"
                (s, eventArgs) => 
                { 
                    if (eventArgs.DialogResult.Value == true
                    { 
                        this.Scheduler.Appointments.Add( 
                               new Appointment() 
                               { 
                                   Start = timeSlotItem.TimeSlot.Start, 
                                   End = timeSlotItem.TimeSlot.End, 
                                   Subject = sourceListBoxItem.FindChildByType<TextBlock>().Text 
                               } 
                           ); 
                        this.source.Remove(sourceListBoxItem.Content.ToString()); 
                    } 
                } 
                ); 
        } 

    ... you will achieve exactly what you need - a confirmation window upon adding an item to the scheduler. For more info on types of windows review the online demos.

    Hope this will be of use!

    Sincerely yours,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  10. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 24 Aug 2009 Link to this post

    Hi Teodor,

      Thanks for the response and code.
      But my requirement is different. Could you please find my requirement below.

      1. In Child window I have to select the Date and Time.
      2. After clicking on Ok / Accept button in Childwindow. I have to add the dropped Appointment in that perticular selected date (Which I will be selecting in the Childwindow).
     
     I think you got my problem. Can you please help me on this.

    Regards
    Satish
  11. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 24 Aug 2009 Link to this post

    Hello Satish,

    Please find attached a slightly modified version of the example, featuring a custom RadWindow which is called similarly as RadWindow.Prompt() calls a window. Feel free to modify it in order to meet your demands.

    You could use Telerik's RadWindow.Prompt() method instead of RadWindow.Confirm() suggested my previous post, however, the input in this case will be a simple text box. If this does not suit your needs, use the technique in the attachment.

    Hope this clarifies the situation.

    Greetings,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  12. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 24 Aug 2009 Link to this post

    Hi Teodor,

      Thanks a lot for the response and Sample.
      But I can't able to run your sample. When ever I try to run this I am getting the following error.

    String reference not set to an instance of a String.
    Parameter name: s

    CustomRadWindow.Prompt((s, eventArgs) =>  
                        {  
                            if (eventArgs.DialogResult.Value == true)  
                            {  
                                this.Scheduler.Appointments.Add(  
                                       new Appointment()  
                                       {  
                                           Start = DateTime.Parse(eventArgs.PromptResult),  
                                           End = DateTime.Parse(eventArgs.PromptResult).AddHours(24),  
                                           Subject = sourceListBoxItem.FindChildByType<TextBlock>().Text  
                                       }  
                                   );  
                                this.source.Remove(sourceListBoxItem.Content.ToString());  
                            }  
                    }); 


    Can you please check this once. And help me to resolve my problem.

    Thanks & Kind Regards
    Satish
  13. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 25 Aug 2009 Link to this post

    Hi satish,

    Sorry for the non-working code and any inconveniences it may have caused. Please find attached the working one.

    Hope it helps.

    Greetings,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  14. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 26 Aug 2009 Link to this post

    Hi Teodor,

      Thanks a lot for your response and sample. If possible can you please make this sample in vb.net. 

      I tried to rewrite  this in to vb.net, then I am getting a lot of problems. If possible could you please send me the working VB.NET sample. 

      And one thing I want to bring to your notice. I want to show the listitem dropped date in the datetimepicker initially. If user want's to chanage the date  he can able to change also.

    A head of you for your response.

    Thanks & Kind Regards
    Satish
  15. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 26 Aug 2009 Link to this post

    Hi Teodor,

     I have rewritten you C# sample in to VB.NET. I am getting problem when i try to write like this.
    Public Overloads Shared Sub Prompt(ByVal eventArgs As EventHandler(Of WindowClosedEventArgs))  
     
            Dim window = New CustomRadWindow()  
            window.Show()  
            window.Closed += eventArgs  
     
        End Sub 

    I am getting the problem in this line.

     

     

    window.Closed += eventArgs

    Now I am able to add the appointment without Customwindow. If i try to use the custom window I am getting the problem.

    Can you please help me on this.

    Regards
    Satish

     

     

     

  16. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 27 Aug 2009 Link to this post

    Hi Teodor,

     I have rewritten the exsiting C# CustomWindow Prompt method (which is available in the following sample) in to VB.NET code. Could you please look in to the following code snippet.

        Public Overloads Shared Sub Prompt(ByVal eventArgs As EventHandler(Of WindowClosedEventArgs))  
            Dim window = New CustomRadWindow()  
            window.Show()  
            AddHandler window.Closed, AddressOf OnWindowClosed  
        End Sub 
        Private Sub OnWindowClosed(ByVal sender As ObjectByVal e As WindowClosedEventArgs)  
            RadWindow.Alert(e.PromptResult)  
        End Sub 
     

    In the above prompt method I am getting error at the below line.
    AddHandler window.Closed, AddressOf OnWindowClosed 

    Error Is:

     Can not refer to an instance of a class from with in a shared method or shared member initializer without an explicit instance of the class. 


    Can you please help me to resolve this. It's very urgent for me.
    A head of you for your response.

    In advance thanks for your time.

    Thanks  & Regards
    Satish
  17. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 27 Aug 2009 Link to this post

    Hi satish,

    The very last issue should be fixed if you use the OnWindowClosed handler of the window instance declared in the current scope (since the call is from a method declared Shared):

    AddHandler window.Closed, AddressOf window.OnWindowClosed  

    Looking into your last but one post, here is the code that should work:

    AddHandler window.Closed, AddressOf eventArgs 

    Hope this helps. Get in touch with us should you have other queries.

    Regards,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  18. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 27 Aug 2009 Link to this post

    Hi Teodor,

     I have used the same code eventhough I am getting the following error in the same line. Please see the modified code.

        Public Overloads Sub Prompt(ByVal eventArgs As EventHandler(Of WindowClosedEventArgs))  
            Dim window = New CustomRadWindow()  
            window.Show()  
     
            AddHandler window.Closed, AddressOf eventArgs  
     
        End Sub 
     

     

    AddressOf operand must be the name of a method (without parentheses)


    In Your attached sample we are calling like this.

    CustomRadWindow.Prompt((s, eventArgs) =>  
    {  
        if (eventArgs.PromptResult == null)  
        {  
            if (eventArgs.DialogResult.Value == true)  
            {  
            this.Scheduler.Appointments.Add(  
              new Appointment()  
              {  
                   Start = DateTime.Parse(eventArgs.PromptResult),  
                   End = DateTime.Parse(eventArgs.PromptResult).AddHours(24),  
                   Subject = sourceListBoxItem.FindChildByType<TextBlock>().Text  
              }  
            );  
        }  
    }  
     

    How to call the same in VB.NET

    Could you please help me on this.

    Thanks inadvance for your time.

    Thanks & Regards
    Satish
  19. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 28 Aug 2009 Link to this post

    Hello satish,

    The very same code in C# stated in your last post is equal to the following code "translated" into VB:

    CustomRadWindow.Prompt(Function(s, eventArgs) Do 
        If eventArgs.PromptResult Is Nothing Then 
            If eventArgs.DialogResult.Value = True Then 
                Dim appointment As New Appointment() 
                appointment.Start = DateTime.Parse(eventArgs.PromptResult) 
                appointment.[End] = DateTime.Parse(eventArgs.PromptResult).AddHours(24) 
                appointment.Subject = sourceListBoxItem.FindChildByType(Of TextBlock)().Text 
                Me.Scheduler.Appointments.Add(appointment) 
            End If 
        End If 
    End Function

    I suggest you to use our online code converter to convert C# to VB or vice versa.

    Hope this helps!

    Greetings,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  20. satish
    satish avatar
    52 posts
    Member since:
    Apr 2009

    Posted 28 Aug 2009 Link to this post

    Hi Teodor,

    Please see the below code which i have written in CustomWindow.xaml.vb for Prompt.
    Public Overloads Sub Prompt(ByVal eventArgs As EventHandler(Of WindowClosedEventArgs))  
            Dim window = New CustomRadWindow()  
            window.Show()  
            AddHandler window.Closed, AddressOf eventArgs.ToString  
        End Sub 

    I tried with the most of the online code converter tools.

    And I have added the converted code which you have sent to me in this mail thread.   Eventhough I am getting the errors. Please find the support ticket details below.

    Can you please look in to this and help me.

     

    Your ticket ID is : 238580

    For reference, please use this number support ticket number.

    Thanks In advance for your time.

    Regards
    Satish

  21. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 28 Aug 2009 Link to this post

    Hi satish,

    I have posted you a reply in the support ticked you have sent to us. Let us continue our communication there.

    Thank you in advance.

    Kind regards,
    Teodor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner