We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

range day timeslot and calendar size

Hi
I can't find the way to pass to my customized form AppointmentForm the end time of the selected interval, for example in my picture (12:00)
I can only detect the time when I click thanks to the scheduleControl1_ScheduleAppointmentClick event and e.ClickDateTime. Also, how can I increase the width of the calendar that appears to be cut off? (please see the picture attached)
Thank you in advance,
Claudio



7 Replies

AR Arulpriya Ramalingam Syncfusion Team September 23, 2019 12:25 PM UTC

Hi Claudio, 
 
Thanks for your interest in Syncfusion products. 
 
I can't find the way to pass to my customized form AppointmentForm the end time of the selected interval, for example in my picture (12:00) 
I can only detect the time when I click thanks to the scheduleControl1_ScheduleAppointmentClick event and e.ClickDateTime. 
By default, the start and end time of the selected ranges will be added in the Appointment form when the form is opened. In order to open get the start and end date time, the AppointmentShowing event will be used and in which, the StartTime and EndTime of the item can be used. Please refer to the below code. 
 
Code example 
 
//Event subscription 
scheduleControl1.ShowingAppointmentForm += ScheduleControl1_ShowingAppointmentForm; 
 
//Event customization 
private void ScheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointFormEventArgs e) 
{ 
    DateTime startTime = e.Item.StartTime; 
    DateTime endTime = e.Item.EndTime; 
    //code perform actions with start and end time. 
} 
 
Note : The appointment form will be displayed by right clicking on the selected range and selecting the New Item menu. 
 
Also, how can I increase the width of the calendar that appears to be cut off? (please see the picture attached) 
In order to change the width for the Calender of the ScheduleControl, the NavigationPanel width can be used. Please make use of the below code and sample. 
 
Code example 
 
//To chage the calender width. 
this.scheduleControl1.NavigationPanel.Width = 300; 
 
 
 
Please revert to us, if we misunderstood your requirement. 
 
Regards, 
Arulpriya 



CL Claudio September 24, 2019 04:31 PM UTC

Hi Arulpriya,
thank you for the answer.
My problem is that when I select the empty cells I don't have any item and I can't read e.Item.StartTime and e.Item.EndTime
What I want to do is to pass to my customized appointment the start and the end time values of the empty cells selected and  create a new item from there, as you do when you create a new appointment with your appointment form..
As you can see in the picture attached, in my case I need to pass the values 10 as start and 12 as end
Regards,
Claudio


AR Arulpriya Ramalingam Syncfusion Team September 25, 2019 11:56 AM UTC

Hi Claudio, 
 
Thanks for the update. 
 
We could understand the use case and to update the start and end DateTime of the new item in the CustomAppointment form, ShowingAppointment event can be used to set the custom appointment forms value. We have created a simple sample based on your requirement and please make use of the below code and sample. 
 
Code example 
 
void scheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointFormEventArgs e) 
{ 
    //To update the DateTime in custom form 
    form.NewItem = e.Item; 
    //Cancel the default appointform for schedule control 
    e.Cancel = true; 
    //Shows the Custom appointment form 
    form.ShowDialog(); 
} 
 
//In AppointmentForm class file 
private void AppointmentForm_Load1(object sender, EventArgs e) 
{ 
    this.StartDateDateTimePickerAdv.Value = NewItem.StartTime.Date; 
    this.StartTimeDateTimePickerAdv.Value = NewItem.StartTime; 
    this.EndDateDateTimePickerAdv.Value  = NewItem.EndTime.Date; 
    this.EndTimeDateTimePickerAdv.Value = NewItem.EndTime; 
} 
 
public IScheduleAppointment NewItem 
{ 
    get;set; 
} 
 
 
Regards, 
Arulpriya 



CL Claudio September 28, 2019 09:46 AM UTC

Dear Arulpriya,
Sorry but I still don't get how it works.
Even in your example attached, when i click on add appointment, after selected the cells empty:



I have the following error:


because the NewItem is null.

Please help me!

Best regards,
Claudio


AR Arulpriya Ramalingam Syncfusion Team September 30, 2019 01:20 PM UTC

Hi Claudio,

 

Sorry for the inconvenience.

 

The custom AppointmentForm is directly shown when the AddAppointment menu item is clicked in the provided sample. So, the NewItem is not updated with start and end time. In order to overcome this scenario, the PerformNewItemClick method of ScheduleControl can be called when the AddAppointment menu button is clicked. So, the NewItem will be updated with item start and end time details. We have modified the sample as per your requirement and please make use of the below code sample.

 

Code example

 

void item_Click(object sender, EventArgs e)

{

    //To update the new item when the empty range is clicked to add appointment.

    this.scheduleControl1.PerformNewItemClick();

 

    //if (form != null)

    //{

    //    form.ShowDialog();

    //}

}

 

void scheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointFormEventArgs e)

{

    //To update the DateTime in custom form

    form.NewItem = e.Item;

    //Cancel the default appointform for schedule control

    e.Cancel = true;

    //Shows the Custom appointment form

    form.ShowDialog();

}

 

Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CS-714958731

 

Please get back to us, if you need any further assistance.

 

Regards,

Arulpriya




CL Claudio October 2, 2019 11:15 AM UTC

Thank you,
now it works, but when I change the selection on the calendary (daily,week or month), the Item menu change from customized (add appointment) to the standard one (new item, edit item...), in your example too.
Ho can I avoid this?

Regards,
Claudio


AR Arulpriya Ramalingam Syncfusion Team October 3, 2019 12:28 PM UTC

Hi Claudio, 
 
Thanks for the update. 
 
We have analyzed the reported use case and modified the sample. In the provided sample ContextMenu was reset when the grid for the calendar created and this can be handled by using the SetupContextMenu. Please make use of the below code and sample. 
 
Code example 
 
//Event triggering 
this.scheduleControl1.ScheduleGridCreated += ScheduleControl1_ScheduleGridCreated; 
scheduleControl1.SetupContextMenu += ScheduleControl1_SetupContextMenu; 
 
private void ScheduleControl1_SetupContextMenu(object sender, CancelEventArgs e) 
{ 
    e.Cancel = true; 
  //To set the context menu for grid 
  this.scheduleControl1.GetScheduleHost().ContextMenu = menu; 
} 
 
 
Please revert to us, if you need any further assistance. 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon