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

Can't find resources while adding new appointment

5 Answers 173 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Manmeet
Top achievements
Rank 1
Manmeet asked on 09 Aug 2010, 03:18 PM
hi

I am new to telerik controls so please help me to sort out this problem.

I am using AdvanceInsert and AdvanceEdit template to save and edit the appointments. i also used resources and custome attributes in scheduler to match my requirements, but i wasn't been able to fetch the resources values on "schActivities_AppointmentInsert" event.

let me show you my code to explain the issue.

In aspx
<telerik:RadScheduler ID="schActivities" Width="100%" Height="100%" runat="server"
        Skin="Office2007" SelectedView="MonthView" DayStartTime="08:00:00" DayEndTime="18:00:00"
        TimeZoneOffset="03:00:00" DataKeyField="ID" DataSubjectField="ActName" DataDescriptionField="Description" DataStartField="StartDate"
        DataEndField="EndDate" OnClientTimeSlotContextMenu="OnClientTimeSlotContextMenu"
        OnFormCreated="OnFormCreated" StartInsertingInAdvancedForm="true" StartEditingInAdvancedForm="true"
        OnTimeSlotContextMenuItemClicking="OnTimeSlotContextMenuItemClicking" OnClientFormCreated="schedulerFormCreated" AllowDelete="false" CustomAttributeNames="ActType,Priority,Location,ContactIDs,Notes">
        <AdvancedForm Modal="true" Enabled="true" Width="570" />
        <TimelineView UserSelectable="false" />
        <TimeSlotContextMenuSettings EnableDefault="true" />
        <AppointmentContextMenuSettings EnableDefault="true" />
        <ResourceTypes>
            <telerik:ResourceType KeyField="Value" Name="ActType" TextField="Value" ForeignKeyField="ActType" />
            <telerik:ResourceType KeyField="Value" Name="Priority" TextField="Value" ForeignKeyField="Priority" />
        </ResourceTypes>
        <ResourceStyles>
            <telerik:ResourceStyleMapping Type="Priority" Text="Low" ApplyCssClass="rsCategoryGreen" />
            <telerik:ResourceStyleMapping Type="Priority" Text="Medium" ApplyCssClass="rsCategoryOrange" />
            <telerik:ResourceStyleMapping Type="Priority" Text="High" ApplyCssClass="rsCategoryBlue" />
        </ResourceStyles>
        <AppointmentTemplate>
            <img src='<%# "../Images/Schedule" + Eval("ActType") +".gif" %>' alt=" " title='<%# Eval("ActType") %>' />
            <asp:Label ID="lblSubject" runat="server" Text='<%# Eval("Subject") %>' />
            <%--Text='<%# (Convert.ToString(Eval("Subject")).Length > 10) ? Convert.ToString(Eval("Subject")).Substring(0,10) : Eval("Subject") %>'--%>
        </AppointmentTemplate>
        <TimeSlotContextMenus>
            <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerTimeSlotContextMenu">
                <Items>
                    <telerik:RadMenuItem Selected="true" Text="Schedule a meeting" Value="CommandAddAppointment" />
                    <telerik:RadMenuItem Text="Schedule a call" Value="CommandAddAppointment" />
                    <telerik:RadMenuItem Text="Schedule a task" Value="CommandAddAppointment" />
                    <telerik:RadMenuItem IsSeparator="true" />
                    <telerik:RadMenuItem Selected="true" Text="Un-Scheduled activities">
                        <Items>
                            <telerik:RadMenuItem Text="Create a meeting" Value="CommandAddAppointment" />
                            <telerik:RadMenuItem Text="Make a call" Value="CommandAddAppointment" />
                            <telerik:RadMenuItem Text="Create a task" Value="CommandAddAppointment" />
                        </Items>
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem IsSeparator="true" />
                    <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                </Items>
            </telerik:RadSchedulerContextMenu>
        </TimeSlotContextMenus>
        <AppointmentContextMenus>
            <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">
                <Items>
                    <telerik:RadMenuItem Text="Edit" Value="CommandEdit" />
                    <telerik:RadMenuItem IsSeparator="True" />
                    <telerik:RadMenuItem Text="Export to iCal" />
                </Items>
            </telerik:RadSchedulerContextMenu>
        </AppointmentContextMenus>
        <AdvancedInsertTemplate>
            <Scheduler:AdvancedForm runat="server" ID="ucAdvForm_Insert" Mode="Insert" Subject='<%# Bind("Subject") %>'
                Description='<%# Bind("Description") %>' ActType="Meeting" Start='<%# Bind("Start") %>'
                End='<%# Bind("End") %>' ContactIDs='<%# Bind("ContactIDs") %>' />
        </AdvancedInsertTemplate>
        <AdvancedEditTemplate>
            <Scheduler:AdvancedForm runat="server" ID="ucAdvForm_Edit" Mode="Edit" Subject='<%# Bind("Subject") %>'
                Description='<%# Bind("Description") %>' ActType="Meeting" Start='<%# Bind("Start") %>'
                End='<%# Bind("End") %>' ContactIDs='<%# Bind("ContactIDs") %>' />
        </AdvancedEditTemplate>
    </telerik:RadScheduler>


In cs file
protected void schActivities_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
//code
        }
 
 
        protected void schActivities_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
        {
        }

but i wasn't been able to get resources values in insert event.  actually in my scheduler there are three kind of appointment "Meeting", "Call", "Task" and i need to set the Activity Type on insert command, but i can't find it through resources. Please help me in this.

Regards
Manmeet Singh

5 Answers, 1 is accepted

Sort by
0
Manmeet
Top achievements
Rank 1
answered on 10 Aug 2010, 09:23 AM
Telerik...are you out there?  Are you going to be able to help or do you need more info?
0
Manmeet
Top achievements
Rank 1
answered on 12 Aug 2010, 08:23 AM
hi everyone

Please help in this problem, i really need to complete this at priority.

Regards
Manmeet Singh
0
Veronica
Telerik team
answered on 12 Aug 2010, 11:29 AM
Hi Manmeet,

Each Appointment object has a Resources property, which is a collection of Resource objects that is assigned to the appointment. When working with the Resources property of an appointment, use the GetResourceByType method to obtain a reference to the single value of that resource type that is assigned to the appointment. If the resource supports multiple values for a single resource type, you can use the GetResourcesByType method instead.

You can use the following code to get the resource on Inserting:

protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            Resource resource = e.Appointment.Resources.GetResourceByType("ActType");
        }

Analogically for Update:

protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
   {
       Resource resource = e.Appointment.Resources.GetResourceByType("ActType");                
   }

Please let me know if you have more questions.

Greetings,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Manmeet
Top achievements
Rank 1
answered on 12 Aug 2010, 12:03 PM
Hi Veronica

I tried this thing but in insert event i got e.Appointment.Resources.count =0, but in case of update resources works fine. am i doing some thing wrong.

Regards
Manmeet Singh
0
Accepted
Veronica
Telerik team
answered on 12 Aug 2010, 04:10 PM
Hello Manmeet,

It is normal that while inserting you get e.Appointment.Resources.Count = 0. The reason is that via e.Appointment you get the current appointment object which is to be inserted. It has no resources. They are to be set at this moment.

If you want to set resources in the AppointmentInsert event handler then you'll have to get them from the RadScheduler object: RadScheduler1.Resources (where RadScheduler1 is the ID of the Scheduler).

Greetings,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Manmeet
Top achievements
Rank 1
Answers by
Manmeet
Top achievements
Rank 1
Veronica
Telerik team
Share this question
or