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

Resource grouping with object datasources

1 Answer 38 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
David Penny
Top achievements
Rank 2
David Penny asked on 20 Oct 2009, 04:07 PM
Hi,

I'm not sure why but I just don't seem to be getting grouping by Resource.

I want to have a Scheduler show Staff down the left hand side, time horizontally, and based on the examples this looks like grouping by Staff, but all the examples seem to use either a direct connection or session datasources.

I am populating my Scheduler by assigning a datasource in code (RadScheduler1.datasource = myDataSource) and all OK.

Do you have any help or examples that might show me how to do the same with my Resources as well, and then how to Group these, all within code rather than declaratively?

David Penny

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 27 Oct 2009, 10:02 AM
Hi David,

Please, refer to the Binding to generic list demo. In this demo the resources are defined manually like this:
private void InitializeResources()
        {
            ResourceType resType = new ResourceType("User");
            resType.ForeignKeyField = "UserID";
  
            RadScheduler1.ResourceTypes.Add(resType);
            RadScheduler1.Resources.Add(new Resource("User", 1, "Alex"));
            RadScheduler1.Resources.Add(new Resource("User", 2, "Bob"));
            RadScheduler1.Resources.Add(new Resource("User", 3, "Charlie"));
        }

Then, they are added in OnInit:
protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
  
            if (!IsPostBack)
            {
                Session.Remove(AppointmentsKey);
  
                InitializeResources();
                InitializeAppointments();
            }
  
            RadScheduler1.DataSource = Appointments;
        }

However, you can set DataSource or DataSourceId for your Resource type. Here are the properties which you need to set:
* * *
<telerik:ResourceType KeyField="ID" Name="Room" TextField="RoomName" ForeignKeyField="RoomID" DataSourceID="RoomsDataSource" />
* * *
These properties can be set in code behind as well.

The important thing is that you use OnInit to add the resources.

Feel free to contact us if you have any other questions.


All the best,
Peter
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.
Tags
Scheduler
Asked by
David Penny
Top achievements
Rank 2
Answers by
Peter
Telerik team
Share this question
or