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

Dynamic ResourceType

2 Answers 80 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Felipe Saldana
Top achievements
Rank 1
Felipe Saldana asked on 25 Jan 2009, 10:11 PM

Can someone show me (or direct me to) how to dynamically add a ResourceType?

I have tried the code below and I dont have the ResourceType available in the AppointmentCreated event

            ResourceType rt = new ResourceType();  
            rt.DataSource = properties;  
            rt.ForeignKeyField = "PropertyId";  
            rt.KeyField = "PropertyId";  
            rt.Name = "Property";  
            rt.TextField = "title";  
                          
            this.RadScheduler1.ResourceTypes.Add(rt); 
    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)  
    {  
        Resource prop = e.Appointment.Resources.GetResourceByType("Property");  
 
        if (prop != null)  
        {  
            e.Appointment.CssClass = "ID" + prop.Key.ToString();                  
        }  
    }  
 

Do I need to populate the ResourceType at a particular point in the page life cycle?

This will tell me the property that is associated to the given appointment correct? 


Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 26 Jan 2009, 02:25 PM
Hello Felipe,

I assume this code is in the Page Load event. It looks correct to me. Just make sure the KeyField and ForeignKeyField are of the same data type. I have attached a small demo for reference.


Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Felipe Saldana
Top achievements
Rank 1
answered on 26 Jan 2009, 09:06 PM
Thanks... I needed to add this to the Page Load event.
Tags
Scheduler
Asked by
Felipe Saldana
Top achievements
Rank 1
Answers by
Peter
Telerik team
Felipe Saldana
Top achievements
Rank 1
Share this question
or