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

Subject doesn't appear

3 Answers 71 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 05 Oct 2012, 08:43 PM
In the process of updating some functionality I refactored out a user control (below).
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TeamTodayScheduler.ascx.cs" Inherits="Private_Dashboard_TeamTodayScheduler" %>
 
<telerik:RadAjaxManager ID="ramTeamToday" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="lb">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="rsTeamToday" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<asp:LinkButton ID="lb" runat="server" CssClass="customRSHeader" ForeColor="#333" Width="100%" OnClick="lb_Click" />
<telerik:RadScheduler ID="rsTeamToday" runat="server" AllowDelete="false" AllowEdit="false" AllowInsert="false"
        ShowFooter="false" ShowHeader="false" ShowResourceHeaders="false" SelectedView="TimelineView"
        OverflowBehavior="Expand" Visible="false" DataSourceID="ldsSchedules" DataKeyField="ScheduleID"
        DataStartField="ScheduleStartDate" DataEndField="ScheduleEndDate" DataSubjectField="EmployeeName"
        DataRecurrenceField="ScheduleRecurrenceRule" DataRecurrenceParentKeyField="ScheduleRecurrenceParentID"
        OnTimeSlotCreated="rsToday_TimeSlotCreated">
    <TimelineView GroupBy="Employee" GroupingDirection="Vertical" ReadOnly="true" ShowInsertArea="false"
        StartTime="08:00:00" SlotDuration="00:15:00" NumberOfSlots="36" TimeLabelSpan="4"
        ColumnHeaderDateFormat="h tt" EnableExactTimeRendering="true" />
    <ResourceTypes>
        <telerik:ResourceType KeyField="EmployeeID" Name="Employee" TextField="EmployeeID"
            ForeignKeyField="ScheduleEmployeeID" DataSourceID="ldsEmployees" />
        <telerik:ResourceType KeyField="ScheduleActivityTypeID" Name="Activity" TextField="ScheduleActivityTypeName"
            ForeignKeyField="ScheduleActivityTypeID" DataSourceID="ldsActivityTypes" />
    </ResourceTypes>
    <ResourceStyles>
        <telerik:ResourceStyleMapping Type="Activity" Text="Work" ApplyCssClass="WorkSchedule" />
        <telerik:ResourceStyleMapping Type="Activity" Text="Class" ApplyCssClass="ClassSchedule" />
        <telerik:ResourceStyleMapping Type="Activity" Text="Sick" ApplyCssClass="SickSchedule" />
        <telerik:ResourceStyleMapping Type="Activity" Text="Vacation" ApplyCssClass="VacationSchedule" />
        <telerik:ResourceStyleMapping Type="Activity" Text="Extended Leave of Absence" ApplyCssClass="OffSiteSchedule" />
    </ResourceStyles>
</telerik:RadScheduler>
<asp:LinqDataSource ID="ldsActivityTypes" runat="server" ContextTypeName="SciNET.BusinessObjects.SciNETDataContext"
    TableName="ScheduleActivityTypes" />
<asp:LinqDataSource ID="ldsEmployees" runat="server" ContextTypeName="SciNET.BusinessObjects.SciNETDataContext"
        TableName="Employees" OnSelecting="ldsEmployees_Selecting">
    <WhereParameters>
        <asp:Parameter DbType="Int32" Name="TeamID" />
    </WhereParameters
</asp:LinqDataSource>
<asp:LinqDataSource ID="ldsSchedules" runat="server" ContextTypeName="SciNET.BusinessObjects.SciNETDataContext"
    TableName="Schedules" OrderBy="ScheduleActivityTypeID Descending" OnSelecting="ldsSchedules_Selecting" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SciNET.BusinessObjects;
using Telerik.Web.UI;
 
public partial class Private_Dashboard_TeamTodayScheduler : System.Web.UI.UserControl
{
    protected SciNETDataContext dbContext = new SciNETDataContext();
 
    public int TeamID
    {
        get { return Convert.ToInt32(ldsEmployees.WhereParameters["TeamID"].DefaultValue); }
        set { ldsEmployees.WhereParameters["TeamID"].DefaultValue = value.ToString(); }
    }
 
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lb.Text = TeamID == 0 ? "Full-Timers" : (from team in dbContext.EmployeeTeams
                                                     where team.EmployeeTeamID == TeamID
                                                     select team).Single().EmployeeTeamName;
        }
    }
 
    protected void lb_Click(object sender, EventArgs e)
    {
        rsTeamToday.Visible = !rsTeamToday.Visible;
    }
 
    protected void rsToday_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        if (e.TimeSlot.Start <= DateTime.Now && e.TimeSlot.End >= DateTime.Now) e.TimeSlot.CssClass = "Highlight";
    }
 
    protected void ldsEmployees_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        if (TeamID == 0) e.Result = (from emp in dbContext.Employees
                                     where !emp.EmployeeDateTerminated.HasValue
                                     where emp.EmployeeRoles.Count(role => role.EmployeeRoleTypeID == 0) > 0
                                     select emp).ToList();// 0 stands for Full-timer ^^^
        else e.Result = (from emp in dbContext.Employees
                         where !emp.EmployeeDateTerminated.HasValue
                         where emp.EmployeeTeamID == Convert.ToInt32(e.WhereParameters["TeamID"])
                         where emp.EmployeeRoles.Count(role => role.EmployeeRoleTypeID == 0) == 0
                         select emp).ToList();
        if (((List<Employee>)e.Result).Count == 0) Visible = false;
    }
 
    protected void ldsSchedules_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {// Note: This grabs everyone's schedules. It's easier to let the grouping filter out the ones we don't need.
        e.Result = (from schedule in dbContext.Schedules
                    orderby schedule.ScheduleActivityTypeID descending
                    select new
                    {
                        ScheduleID = schedule.ScheduleID,
                        ScheduleSubject = schedule.ScheduleSubject,
                        ScheduleActivityTypeID = schedule.ScheduleActivityTypeID,
                        ScheduleStartDate = schedule.ScheduleStartDate,
                        ScheduleEndDate = schedule.ScheduleEndDate,
                        ScheduleEmployeeID = schedule.ScheduleEmployeeID,
                        ScheduleRecurrenceRule = schedule.ScheduleRecurrenceRule,
                        ScheduleRecurrenceParentID = schedule.ScheduleRecurrenceParentID,
                        EmployeeName = schedule.Employee.EmployeeGivenName + " " + schedule.Employee.EmployeeLastName
                    }).ToList();
    }
}
As is, a javascript TypeError: Telerik.Web.UI.RadScheduler is undefined appears, the scheduler renders and works in every aspect except that the appointments' subjects don't appear. Removing both resource types (not just one) displays the subjects. Moving the code back to the parent page just throws slightly different javascript errors--c[0] or n is undefined; usually related to some sorting thing--but visually makes no change. It seems independent of all other properties of the radscheduler. I've looked at similar issues that suggested the web.config needed a handler, but mine's setup correctly. Another suspected the grouping, but that's not the issue here.
An appointment template ignores the data; it'll display hard-coded content. The data is accessible in the code-behind, and I've used it to manipulate the Tooltip which works fine, but the appointment subject refuses to display.

From what I've gathered, it's not connecting the scripts RadScheduler needs to run, but the fix they recommended (EnableEmbeddedScripts) didn't work for me.

3 Answers, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 08 Oct 2012, 03:26 PM
Any help would be appreciated. Thanks.
0
Matthew
Top achievements
Rank 1
answered on 09 Oct 2012, 02:19 PM
As you can see, the initial setting for the RadScheduler's visibility is false. From my stumbling around, it appears that because of this, I have to rebind the scheduler when I want to show it in order to get the subject to appear.
0
Boyan Dimitrov
Telerik team
answered on 10 Oct 2012, 01:57 PM
Hello Matthew,

I prepared a sample project based on our online demo that shows populating data using LinqDataSource  and your markup code. Since your project uses lots of custom data I was unable to reproduce your issue at my side.
Could you please modify the attached project, so we can inspect the problem locally?

I am waiting to your reply.

Regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or