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

How to get Name or Index of currently selected Resource.

I use two Resource Types with several resources in each type. When adding new appointment through context menu, need to know a name of a resource on which mouse was clicked, to use it in:

appointment.ResourceCollection.Add(new Resource()

{

ResourceName = "Symbol1",

TypeName = "Symbols"

});

Knowing ResourceName is required while adding new appointment under particular resource, otherwise appointment is not displayed.

When I add a new appointment from code behind with: ResourceName = "Symbol1", TypeName = "Symbols" 

then appointment is properly displayed.

For the project I used Custom Appointment Editor from CustomizationDemo.

I checked ScheduleResourcePagerWithExpander but there is no pointer how to get the name or index.

Thanks in advance.


4 Replies

AN Andrzej replied to Andrzej December 19, 2016 10:44 PM UTC

I use two Resource Types with several resources in each type. When adding new appointment through context menu, need to know a name of a resource on which mouse was clicked, to use it in:

appointment.ResourceCollection.Add(new Resource()

{

ResourceName = "Symbol1",

TypeName = "Symbols"

});

Knowing ResourceName is required while adding new appointment under particular resource, otherwise appointment is not displayed.

When I add a new appointment from code behind with: ResourceName = "Symbol1", TypeName = "Symbols" 

then appointment is properly displayed.

For the project I used Custom Appointment Editor from CustomizationDemo.

I checked ScheduleResourcePagerWithExpander but there is no pointer how to get the name or index.

Thanks in advance.


It seems that Custom Appointment Editor from CustomizationDemo doesn't automatically add appointments to appropriate resources.
Regular Appointment Editor in ResourceDemo adds new appointments to selected resources without any additional help.
Please advise.


JM Jeyasri M Syncfusion Team December 20, 2016 11:03 AM UTC

Hi Andrzej, 
 
Thanks for your interest in Syncfusion products. 
 
By using the SfSchedule AppointmentEditorOpening event you can get the selected Resource details. Based on your requirement we have modified the Customization sample and please find the sample from below link. 
 
In the above sample, we have used AppointmentEditorOpening event to get the selected Resource details and corresponding ResourceCollection has been added while creating newly appointment. 
 
Please find the modified Code Snippet as follows. 
 
Code Snippet: 
 
    void Schedule_AppointmentEditorOpening(object sender, AppointmentEditorOpeningEventArgs e) 
        { 
            e.Cancel = true; 
            AddDataContext = new BindingClass() {CurrentSelectedDate = e.StartTime, Appointment = e.Appointment,}; 
            SelectedResource = new ObservableCollection<object>(); 
 
            foreach (var item in e.SelectedResource) 
                SelectedResource.Add(item); 
            ……………… 
        } 
 
Regards, 
Jeyasri M.

 



AN Andrzej December 20, 2016 02:44 PM UTC

Provided solution solved the problem. Thank you for fast response and excellent support.


JM Jeyasri M Syncfusion Team December 21, 2016 05:13 AM UTC

Hi Andrzej,  
 
We value your feedback and we glad to know that the given solution worked for you. Please let us know if you need any further assistance. 
 
Regards, 
Jeyasri M. 


Loader.
Live Chat Icon For mobile
Up arrow icon