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

Stopping the in edit in Scheduler

9 Answers 260 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
JK
Top achievements
Rank 1
JK asked on 28 Sep 2007, 11:35 AM
Hi,

I am trying to stop the scheduler from showing the in-edit appointment option. 

To explain, I have created ASP code in the .cs file which, when the user double clicks on the date (in the scheduler) it automatically logs the appointment based on a category of "morning" "afternoon" "all day". 

All of this code works fine, my problem is after you have double clicked on the scheduler it populates the appointment but waits for the user to click the "tick" to commit the changes. 

Can the commit be done within the ASP code at all?  I notice that the rad window example will do this, but in that example the clientside code (javascript) opens the rad window then cancels the appointment, then the radwindow reinserts the appointment.

In my case all my code is via ASP meaning the RadWindow example will not work for me as the clientside script will always fire before the server side. 

Below is a snippet of my code, Can anyone help?
    protected void RadScheduler1_FormCreated(object sender, Telerik.Web.UI.SchedulerFormCreatedEventArgs e)  
    {  
       DropDownList jobtype =  (DropDownList)fvNewService2.FindControl("ddlJobType");  
       DropDownList employee = (DropDownList)fvNewService2.FindControl("ddlEmployee");  
       DropDownList jobstatus = (DropDownList)fvNewService2.FindControl("ddlJobStatus");  
       DropDownList time = (DropDownList)fvNewService2.FindControl("ddlTime");  
       TextBox mileage = (TextBox)fvNewService2.FindControl("ServiceHistoryMilageTextBox");  
       TextBox hoursworked = (TextBox)fvNewService2.FindControl("txHoursWorked");  
       DropDownList paymenttype = (DropDownList)fvNewService2.FindControl("ddlPaymentType");  
       DropDownList paymentstatus = (DropDownList)fvNewService2.FindControl("ddlPaymentStatus");  
       string starttime;  
       string endtime;  
       string thedate;  
 
       thedate = e.Appointment.Start.ToShortDateString();  
       //create code for noew line  
       char chrCR = (char)13;  
       string strCR = chrCR.ToString();  
       char chrLF = (char)10;  
       string strLF = chrLF.ToString();  
       string strCRstrCRLF = strCR + strLF;  
 
//obtain hours based on the form value of time  
        switch (time.SelectedValue)  
        {  
            default:  
                  
                starttime = thedate.ToString() + " 09:00:00";  
                endtime = thedate.ToString() + "17:00:00";  
                break;  
            //Morning  
            case "1":  
                starttime = thedate.ToString() + " 09:00:00";  
                endtime = thedate.ToString() + " 12:00:00";  
                break;  
            //Afternoon  
            case "2":  
                starttime = thedate.ToString() + " 12:00:00";  
                endtime = thedate.ToString() + " 17:00:00";  
                break;  
            //All Day  
            case "3":  
                starttime = thedate.ToString() + " 09:00:00";  
                endtime = thedate.ToString() + " 17:00:00";  
                break;  
        }  
         
        e.Appointment.Start = DateTime.Parse(starttime.ToString());  
        e.Appointment.End = DateTime.Parse(endtime.ToString());  
        e.Appointment.Subject = "Job Type: " + jobtype.SelectedItem.ToString() + strCRLF.ToString()   
            + "Employee:" + employee.SelectedItem.ToString();  
 
    // how do I commit the appointment from here????????????  
          
    } 

9 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 28 Sep 2007, 02:44 PM
Hi JK,

You can handle the FromCreating event instead of FormCreated so you can cancel the event and prevent the Edit Form from appearing. Then just add the appointment 'manually' using the InsertAppointment method. Here is an example:

void RadScheduler1_FormCreating(object sender, Telerik.Web.UI.SchedulerFormCreatingEventArgs e)  
{  
    if (e.Mode == Telerik.Web.UI.SchedulerFormMode.Insert)  
    {  
        e.Appointment.Subject = "New Appointment";  
        RadScheduler1.InsertAppointment(e.Appointment);  
        e.Cancel = true;  
    }  


Sincerely yours,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 28 Sep 2007, 02:54 PM
Thanks!,

I was focused on the "e" value to to consider the radsheduler object itself.

One final thing, I must admit I am self taught on ASP and I am having difficulty in refering to the radscheduler object if it is inside a

ASPformview
    > RADMultipage
        >RADPageView

How would I reference the RAD object?  I know I will need to DIM variables but then I draw a blank.  Can you post an example nested structure to help at all?

Thanks Again.
0
Dimitar Milushev
Telerik team
answered on 28 Sep 2007, 03:15 PM
Hi JK,

I slightly simplified the example code for clarity. A better way to do this would be casting the sender object to RadScheduler. This way you don't need a direct reference, attaching the handler is enough. Here's a better example (in VB, since you mentioned DIM) :

Private Sub Page_Load(ByVal sender As ObjectByVal e As EventArgs)  
    AddHandler RadScheduler1.FormCreating, AddressOf RadScheduler1_FormCreating  
End Sub 
 
Private Sub RadScheduler1_FormCreating(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerFormCreatingEventArgs)  
    If e.Mode = Telerik.Web.UI.SchedulerFormMode.Insert Then 
        Dim scheduler As Telerik.Web.UI.RadScheduler = DirectCast(sender, Telerik.Web.UI.RadScheduler)  
        scheduler.InsertAppointment(e.Appointment)  
        e.Cancel = True 
    End If 
End Sub 

This way you can use the same method for all Schedulers that need it.

Sincerely yours,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 28 Sep 2007, 03:34 PM
yep, this is showing up my newbie-ness :o)

I am coding in C# (use the terms like DIM from my VBA days) so I have had a stab at translating the code but failed miserably :(

Could you post the c# code as well.  Sorry for being a pain...
0
Dimitar Milushev
Telerik team
answered on 28 Sep 2007, 03:37 PM
No problem :)

private void Page_Load(object sender, EventArgs e)  
{  
    RadScheduler1.FormCreating += new Telerik.Web.UI.SchedulerFormCreatingEventHandler(RadScheduler1_FormCreating);  
}  
 
void RadScheduler1_FormCreating(object sender, Telerik.Web.UI.SchedulerFormCreatingEventArgs e)  
{  
    if (e.Mode == Telerik.Web.UI.SchedulerFormMode.Insert)  
    {  
        Telerik.Web.UI.RadScheduler scheduler = (Telerik.Web.UI.RadScheduler)sender;  
        scheduler.InsertAppointment(e.Appointment);  
        e.Cancel = true;  
    }  


Kind regards,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 28 Sep 2007, 03:52 PM
Dimitar,

Sorry for going on, the page load statement wont work because the radscheduler is embedded in a RadMultiPage.  Again I tried to use the code and did this:

 protected void Page_Load(object sender, EventArgs e)  
    {  
        Telerik.Web.UI.RadScheduler scheduler = (Telerik.Web.UI.RadScheduler)sender;  
        scheduler.FormCreating += new Telerik.Web.UI.SchedulerFormCreatingEventHandler(RadScheduler1_FormCreating);    
    } 

I also took out the "sender" as I imagined this would be wrong.... Any ideas?

Thanks
0
Atanas Korchev
Telerik team
answered on 01 Oct 2007, 01:43 PM
Hello JK,

You should use the FindControl method of the pageview where RadScheduler is in.

RadScheduler scheduler = (RadScheduler)RadMultiPage1.PageViews[0].FindControl("RadScheduler1");

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 01 Oct 2007, 02:53 PM
ahh ha!,

Thanks, that now clears that up.  Unfortunately, I now have another error and 1 requirement, but feel I am close to the end of this topic...

1. The Error - I had to debug to discover this error, when the code get to the part where I need to add the subject information, it states that it requires the "New" keyword to create an object instance.  The sample code given to me last week does not refer to the "New" keyword.  I am a bit confused.(Code is added at bottom of this post)

2.  on previous posts I was instructed to put the code for creating the appointment in the "formCreating" event.  The only problem with that is I want the user to double click on the date and for it to pick up the date and via code put it in as either the morning or afternoon appointment(time specified by a drop down list). 
Since the event is form creating, I can no longer see how to obtain the date as the client has only just double clicked and the "e.appointment.start" is not populated yet.  Originally (see above posts) I had this code in the form created event. which meant the date and time were already posted and I could then overwrite them.

Here is my code:
    protected void RadScheduler1_FormCreating(object sender, Telerik.Web.UI.SchedulerFormCreatingEventArgs e)  
    {  
        Telerik.WebControls.RadMultiPage MyMulti = (Telerik.WebControls.RadMultiPage)fvNewService2.FindControl("RadMultiPage1");  
        Telerik.WebControls.PageView MyPageview = (Telerik.WebControls.PageView)MyMulti.PageViews[1];  
        Telerik.Web.UI.RadScheduler Scheduler = (Telerik.Web.UI.RadScheduler)MyPageview.FindControl("RadScheduler1");  
        Label Reg = (Label)FormView1.FindControl("VehicleDetailsRegistrationNumberLabel");  
        DropDownList jobtype = (DropDownList)fvNewService2.FindControl("ddlJobType");  
        DropDownList employee = (DropDownList)fvNewService2.FindControl("ddlEmployee");  
        DropDownList jobstatus = (DropDownList)fvNewService2.FindControl("ddlJobStatus");  
        DropDownList time = (DropDownList)fvNewService2.FindControl("ddlTime");  
        TextBox mileage = (TextBox)fvNewService2.FindControl("ServiceHistoryMilageTextBox");  
        TextBox hoursworked = (TextBox)fvNewService2.FindControl("txHoursWorked");  
        DropDownList paymenttype = (DropDownList)fvNewService2.FindControl("ddlPaymentType");  
        DropDownList paymentstatus = (DropDownList)fvNewService2.FindControl("ddlPaymentStatus");  
        string starttime;  
        string endtime;  
        string thedate;  
 
        thedate = DateTime.Today.ToString(); // e.Appointment.Start.ToShortDateString();  
        //create code for new line  
        char chrCR = (char)13;  
        string strCR = chrCR.ToString();  
        char chrLF = (char)10;  
        string strLF = chrLF.ToString();  
        string strCRstrCRLF = strCR + strLF;  
 
        //obtain hours based on the form value of time  
        switch (time.SelectedValue)  
        {  
            default:  
                starttime = thedate.Substring(1,10).ToString() + " 09:00:00";  
                endtime = thedate.Substring(1, 10).ToString() + "17:00:00";  
                break;  
            //Morning  
            case "1":  
                starttime = thedate.Substring(1,10).ToString() + " 09:00:00";  
                endtime = thedate.Substring(1,10).ToString() + " 12:00:00";  
                break;  
            //Afternoon  
            case "2":  
                starttime = thedate.Substring(1,10).ToString() + " 12:00:00";  
                endtime = thedate.Substring(1,10).ToString() + " 17:00:00";  
                break;  
            //All Day  
            case "3":  
                starttime = thedate.Substring(1,10).ToString() + " 09:00:00";  
                endtime = thedate.Substring(1,10).ToString() + " 17:00:00";  
                break;  
        }  
 
         e.Appointment.Start = DateTime.Parse(starttime.ToString());  
         e.Appointment.End = DateTime.Parse(endtime.ToString());  
         e.Appointment.Subject = Reg.Text + strCRLF.ToString() + jobtype.SelectedItem.ToString() + strCRLF.ToString()  
            + "Employee:" + employee.SelectedItem.ToString();  
 
 
        Scheduler.InsertAppointment(e.Appointment);  
          
        e.Cancel = true;    
       
    } 
0
Dimitar Milushev
Telerik team
answered on 01 Oct 2007, 03:51 PM
Hello,

In the FormCreating event, you can use "e.Time" to obtain the time that the user double-clicked.

As for the first problem - can you please open a support ticket and send us a working project that reproduces the problem? This way we will be able to debug it locally find the problem quicker.

Kind regards,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
JK
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
JK
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or