开发者

Telerik Scheduler with asp.net - Show Everyones meetings in one display

开发者 https://www.devze.com 2023-04-04 19:36 出处:网络
I\'m working on creating a chart with a list people (\"advocates\") and their meetings for a particular day, all in a single view.I\'m using Telerik\'s RadScheduler control (2011 Q2) from their RadCon

I'm working on creating a chart with a list people ("advocates") and their meetings for a particular day, all in a single view. I'm using Telerik's RadScheduler control (2011 Q2) from their RadControls for ASP.NET AJAX package.

I have a M:M relationship between Advocates and Meetings. As such, my database tables are named GRS_Advocate, GRS_Meeting, and GRS_AdvocateToMeeting.

What I am trying to accomplish is to have a list of Advocates on the Y-axis and Times (in one-hour increments) on the top of the X-axis. The closest example on Telerik's website that I can find is http://demos.telerik.com/aspnet-ajax/scheduler/examples/timelineview/defaultcs.aspx here, and this is the one I'm trying to mimic with my data.

Here's a visual representation of what I would like:

Telerik Scheduler with asp.net - Show Everyones meetings in one display

Now, here's a screengrab of what I'm actually getting:

Telerik Scheduler with asp.net - Show Everyones meetings in one display

Those two "Important Meeting" records are for the same meeting, with two different Advocates scheduled to attend. This meeting should be displayed on two different lines, once for each Advocate scheduled to attend, as demonstrated in the first picture.

How do I get to there from here? I suspect the problem might be within the <ResourceTypes> tag I have in the Grid.

Here is the code I've got - I'll share the C# as well although it's likely not as important here.

<telerik:RadScheduler runat="server" ID="RadScheduler1" SelectedView="TimelineView"
    DayStartTime="09:00:00" DayEndTime="19:00:00" DataSourceID="EventsDataSource"
    DataKeyField="ID" DataSubjectField="Subject" DataStartField="Start" DataEndField="End"
     OverflowBehavior="Expand"
    Localization-HeaderMultiDay="Work Week" OnNavigationComplete="RadScheduler1_NavigationComplete">
    <AdvancedForm Modal="true" />
    <ResourceTypes>
        <telerik:ResourceType KeyField="Adv_AdvocateID" Name="Advocate" TextField="Adv_FullName" ForeignKeyField="Adv_AdvocateID"
            DataSourceID="AdvocatesDataSource" />
    </ResourceTypes>
    <TimelineView UserSelectable="true" GroupBy="Adv_AdvocateID" GroupingDirection="Horizontal" />
    <MultiDayView UserSelectable="true" />
    <DayView UserSelectable="false" />
    <WeekView UserSelectable="false" />
    <MonthView UserSelectable="false" />
</telerik:RadScheduler>

</asp:Panel>
<asp:SqlDataSource ID="EventsDataSource" runat="server"
    ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:GRSConnectionString %>"
    SelectCommand="select m.[Id], m.[Room], m.[Start], m.[End], m.[Notes], m.[Subject], a.[Adv_AdvocateID], a.[Adv_FullName] from GRS_Meeting m join GRS_AdvocateToMeeting am on am.Meeting = m.Id join GRS_Advocate a on am.advocate = a.Adv_AdvocateID">
</asp:SqlDataSource>
<asp:SqlDataSource ID="AdvocatesDataSource" runat="server"
    ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:GRSConnectionString %>"
    SelectCommand="SELECT  [Adv_AdvocateID],[Adv_FullName] FROM [GRS_Advocate]">
</asp:SqlDataSource>

And the C# code, if you're interested:

private void Page_Load(object sender, EventArgs e)
    {
        if (RadScheduler1.SelectedView == SchedulerViewType.TimelineView)
        {
            RadScheduler1.TimelineView.SlotDuration = TimeSpan.Parse(DurationList.SelectedValue);
            RadScheduler1.TimelineView.TimeLabelSpan = int.Parse(TimeLabelSpan.SelectedValue);
            RadScheduler1.TimelineView.ColumnHeaderDateFormat = ColumnHeaderDateFormat.SelectedValue;
            RadScheduler1.TimelineView.NumberOfSlots = int.Parse(NumberOfSlotsList.SelectedValue);
            RadScheduler1.TimelineView.GroupingDirection = (GroupingDirection)Enum.Parse(typeof(GroupingDirection), GroupingDirection.SelectedValue);
        }
        else if (RadScheduler1.SelectedView == SchedulerViewType.MultiDayView)
        {
            RadScheduler1.MultiDayView.NumberOfDays = int.Parse(NumberOfDaysList.SelectedValue);
            RadScheduler1.FirstDayOfWeek = (DayOfWeek)int.Parse(FirstDayOfWorkWeekList.SelectedValue);
            RadScheduler1.SelectedDate = RadScheduler1.SelectedDate.AddDays((int)RadScheduler1.FirstDayOfWeek - (int)RadScheduler1.SelectedDate.DayOfWeek);

        }
    }
    protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
    {
        if (RadScheduler1.SelectedView == SchedulerViewType.MultiDayView)
        {

            RadScheduler1.MultiDayView.NumberOfDays = int.Parse(NumberOfDaysList.SelectedValue);
            RadScheduler1.FirstDayOfWeek = (DayOfWeek)int.Parse(FirstDayOfWorkWeekList.SelectedValue);

            //SelectedDate adjustment to make a Work Week view from Multi-day view
            int WorkWeekAdjustmentTimeShift = (int)RadScheduler1.FirstDayOfWeek - (int)RadScheduler1.SelectedDate.DayOfWeek;
            if (e.Command == SchedulerNavigationCommand.NavigateToNextPeriod)
            {
                if (WorkWeekAdjustmentTimeShift < 0)
                    WorkWeekAdjustmentTimeShift += 7;

            }
            else if (e.Command == SchedulerNavigationCommand.NavigateToPreviousPeriod)
            {
                if (WorkWeekAdjustmentTimeShift > 0)
                    WorkWeekAdjustmentTimeShift -= 7;
            }
            RadScheduler1.SelectedDate = RadScheduler1.SelectedDate.AddDays(WorkWeekAdjustmentTimeShift);
        }
    }

I've been working on this for a while now and I just can't get past this point. Any help would be greatly appreciated.

UPDATE

In the comments i开发者_开发知识库t was pointed out that the above image is on Day View, and I should be using Timeline. That is correct; however, when I view Timeline view my advocates aren't listed. In fact, there is nothing but a timeline on the x axis with no y axis at all, and no grid to display:

Telerik Scheduler with asp.net - Show Everyones meetings in one display


To mimic the Demo at hand you would need to use "Timeline View" which is selectable in the "SelectedView" property of the scheduler itself.

Also, to group by Adv_AdvocateID, you need to always reference the "Name" field you give it in the "ResourceTypes" property field.

-:)

0

精彩评论

暂无评论...
验证码 换一张
取 消