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

RedScheduler & Resources Issue

5 Answers 94 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Iain
Top achievements
Rank 1
Iain asked on 15 Jun 2011, 01:15 PM
Hi All,

I'm new to the Telerik comunity and control suite, and after seeing the demo's of the RadScheduler i was blown awa. I've started evaluating whether this control will be able to be encorporated into our creaking architecture and in doing that i've come across a problem i can't quite get my head around. Please note that this is currently using the default XML file for the data provider (i haven't got round to using our database yet).

I've put the following code in the ASPX page:

<telerik:RadScriptManager ID="sman" runat="server" EnableTheming="false"/>
<telerik:RadScheduler ID="radCalendar" runat="server" AdvancedForm-Enabled="true" StartEditingInAdvancedForm="true" StartInsertingInAdvancedForm="true" />

And the following code in the code behind (this is to programmatically add our items to the dropdown, it will be from a database but i'm hardcoding this to mock this for testing purposes).

protected void Page_Init(object sender, EventArgs e)
{
    ResourceType priority = new ResourceType("PriorityLevel");
    radCalendar.ResourceTypes.Add(priority);
    radCalendar.Resources.Add(new Resource("PriorityLevel", 1, "Low"));
    radCalendar.Resources.Add(new Resource("PriorityLevel", 2, "High"));
       
      ResourceType user = new ResourceType("S7User");
      radCalendar.ResourceTypes.Add(user);
      user.AllowMultipleValues = true;
      radCalendar.Resources.Add(new Resource("S7User", 8, "Iain"));
      radCalendar.Resources.Add(new Resource("SUser", 9, "Nick"));
      radCalendar.Resources.Add(new Resource("S7User", 10, "Paul"));
      radCalendar.Resources.Add(new Resource("S7User", 11, "Stephan"));
     radCalendar.Provider = new XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), true);
}

The 'Priority' field now appears as a drop down, as does the S7User, these save too perfectly into the 'Appointments.xml' file, but, when i try to reopen the calendar i get the error:

Cannot find resource of type 'PriorityLevel' with Key=1 for appointment with ID=41.


The XML that is saved in the 'Appointments.xml' file is as follows:

<?xml version="1.0" encoding="utf-8"?>
<Appointments>
  <NextID>42</NextID>
  <Appointment>
    <ID>41</ID>
    <Subject>asdfasdf</Subject>
    <Start>2011-06-15T09:30Z</Start>
    <End>2011-06-15T10:30Z</End>
    <Resources>
      <PriorityLevel Key="1" />
      <S7User Key="8" />
    </Resources>
  </Appointment>
</Appointments>

Can anyone offer any guidance as to why this is happening please? It works when I have the resources in the XML file, but taking them out breaks it, even though they are added to the control. One thing to note is in the Page_Init they are added to the 'Resources' collection in the control.

Any help is greatly appreciated.

Iain

5 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 17 Jun 2011, 03:22 PM
Hello Iain,

Please, make sure that you add the resources in the XML file like this:
<?xml version="1.0" encoding="utf-8"?>
<Appointments>
  <NextID>59</NextID>
  <Resources>
    <PriorityLevel>
      <Key>1</Key>
      <Text>Low</Text>
    </PriorityLevel>
    <PriorityLevel>
      <Key>2</Key>
      <Text>High</Text>
    </PriorityLevel>
    <S7User>
      <Key>7</Key>
      <Text>Iain</Text>
    </S7User>
    <S7User>
      <Key>8</Key>
      <Text>Nick</Text>
    </S7User>
    <S7User>
      <Key>9</Key>
      <Text>Paul</Text>
    </S7User>
    <S7User>
      <Key>10</Key>
      <Text>Stephan</Text>
    </S7User>
  </Resources>
  <Appointment>
    <ID>21</ID>

If you meet other difficulties don't hesitate to ask.

Regards,
Plamen Zdravkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Iain
Top achievements
Rank 1
answered on 17 Jun 2011, 03:39 PM
Thanks Plamen

As i previously said, it works when I have the resources in the XML file, i want to add the resrouces programmatically in the code-behind? Is this possible?

Thanks,

Iain
0
Dan Lehmann
Top achievements
Rank 1
answered on 17 Jun 2011, 04:44 PM
Did you notice that you spelled "S7User" "SUser" for one of the resources?

I am working though similar issues. I found this example project helpful: http://www.telerik.com/community/forums/aspnet-ajax/scheduler/dynamic-resources-in-codebehind.aspx#1325062
0
Iain
Top achievements
Rank 1
answered on 17 Jun 2011, 04:55 PM
Thanks Dan i'll check that out now.
0
Plamen
Telerik team
answered on 21 Jun 2011, 01:22 PM
Hi Iain,

When you use XmlProvider to bind the RadScheduler you can't add the resources programmatically without changing the file. However when you use SqlDataSource you can, as it is shown in the demo in the forum that was posted by Dan.

Best wishes,
Plamen Zdravkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Scheduler
Asked by
Iain
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Iain
Top achievements
Rank 1
Dan Lehmann
Top achievements
Rank 1
Share this question
or