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

Timeline selected date popupCalendar

3 Answers 100 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Claudiu Dordea
Top achievements
Rank 1
Claudiu Dordea asked on 02 Oct 2012, 08:19 AM
Hi
I have a RadScheduler set in timeline mode and I need to display a period of 3 days before and 30 behind a certain date.
When I select the date on the date picker the actual selected date of the timeline has to be SelectedDate.AddDays(-3).
I tried this:
protected void dispTimeline_NavigationCommand(object sender, Telerik.Web.UI.SchedulerNavigationCommandEventArgs e)
        {
            switch (e.Command)
            {
                case Telerik.Web.UI.SchedulerNavigationCommand.NavigateToPreviousPeriod:
                    dispTimeline.SelectedDate = dispTimeline.SelectedDate.AddDays(-1);
                    e.Cancel = true;
                    break;
                case Telerik.Web.UI.SchedulerNavigationCommand.NavigateToNextPeriod:
                    dispTimeline.SelectedDate = dispTimeline.SelectedDate.AddDays(1);
                    e.Cancel = true;
                    break;
                case SchedulerNavigationCommand.SwitchToSelectedDay:
                    dispTimeline.SelectedDate = e.SelectedDate.AddDays(-3);
                    e.Cancel = true;
                    break;
                case SchedulerNavigationCommand.NavigateToSelectedDate:
                    RadCalendar popupCalendar = dispTimeline.FindControl("SelectedDateCalendar") as RadCalendar;
                    dispTimeline.SelectedDate = popupCalendar.SelectedDate.AddDays(-3);
                    // this doesn't work either
                    //dispTimeline.SelectedDate = popupCalendar.FocusedDate;
                    e.Cancel = true;
                    break;
            }
        }

 the SelectedDate of the popupCalendar is the same as the SelectedDate of the timeline and not the date I selected on the page.
After the date is selected in the calendar picker the page does a postback so I tried grabbing the PreRender event of the timeline and see if there is the date that i selected somewhere in the event args but no luck.

How can I find this date, currently if I select a date from the calendar no date is changed so maybe it is my fault so here is my timeline definition
<telerik:RadScheduler ID="dispTimeline" runat="server" DataDescriptionField="Observations"
    DataEndField="ToDate" DataKeyField="ReservationID" DataSourceID="SqlDataSource1"
    DataStartField="FromDate" DataSubjectField="Description"
    DayEndTime="23:59:00" DayStartTime="00:00:00"
    EnableDescriptionField="True" FirstDayOfWeek="Monday"
    HoursPanelTimeFormat="H:mm" LastDayOfWeek="Sunday" SelectedView="TimelineView"
    TimeLabelRowSpan="1" TimeZoneID="GTB Standard Time" TimeZoneOffset="02:00:00"
    WorkDayEndTime="18:00:00" WorkDayStartTime="09:00:00" MinimumInlineFormHeight="200"
    OverflowBehavior="Expand" Localization-HeaderMultiDay="Work Week"
    ColumnWidth="50px" ShowViewTabs="False" OnNavigationCommand="dispTimeline_NavigationCommand"
    AllowDelete="False" AllowEdit="False" AllowInsert="False" OnAppointmentClick="dispTimeline_AppointmentClick"
    GroupingDirection="Vertical" OnDataBound="dispTimeline_DataBound" OnNavigationComplete="dispTimeline_NavigationComplete" SelectedDate="2012-10-01" OnPreRender="dispTimeline_PreRender">
    <AdvancedForm Modal="true" Enabled="False" />
    <ResourceTypes>
        <telerik:ResourceType Name="grpTimeline" DataSourceID="dsGrup" KeyField="ID" TextField="Denumire" ForeignKeyField="" />
        <telerik:ResourceType KeyField="StatusID" Name="Status" TextField="Description" ForeignKeyField="StatusID" DataSourceID="dsStatus" />
    </ResourceTypes>
    <ResourceStyles>
        <telerik:ResourceStyleMapping Type="Status" Text="Rezervare" ApplyCssClass="rsCategoryGreen" />
        <telerik:ResourceStyleMapping Type="Status" Text="Contract in derulare" ApplyCssClass="rsCategoryRed" />
        <telerik:ResourceStyleMapping Type="Status" Text="Contract inchis" ApplyCssClass="rsCategoryBlue" />
        <telerik:ResourceStyleMapping Type="Status" Text="Contract facturat" ApplyCssClass="rsCategoryDarkBlue" />
        <telerik:ResourceStyleMapping Type="Status" Text="Alte rezervari" ApplyCssClass="rsCategoryYellow" />
        <telerik:ResourceStyleMapping Type="Status" Text="Indisponibil" BackColor="DarkGray" />
    </ResourceStyles>
    <Localization HeaderMultiDay="Work Week"></Localization>
 
    <TimelineView HeaderDateFormat="dd.MMM.yyyy" NumberOfSlots="35" SlotDuration="1.00:00:00"
        UserSelectable="true" SortingMode="Global" ColumnHeaderDateFormat="dd.MMM" />
    <MultiDayView UserSelectable="false" />
    <DayView UserSelectable="false" />
    <WeekView UserSelectable="false" />
    <MonthView UserSelectable="false" />
</telerik:RadScheduler>

Thank you

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 03 Oct 2012, 03:43 PM
Hello Claudiu,

Could you please clarify a bit more the scenario you are trying to achieve, so I can help you out? It seems that the provided project works fine with displaying 3 days before and 30 days after the selected date from the popup calendar.
Here you can watch a video in debug mode that shows how you can access the selected date in OnNavigationCommand event using EventArgs e.SelectedDate and this way you are able to set your RadScheduler SelectedDate property to its value.

I hope this information was helpful.

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.
0
Claudiu Dordea
Top achievements
Rank 1
answered on 04 Oct 2012, 07:18 AM
Hi Boyan,
Thanks for your reply,
I am baffled that it works on your side, when I get into the OnNavigationCommand event e.SelectedDate is the same ast dispTimeline.Selected date. it never changes to the date I actually select.
first I thought that I might have set the selectedDate somewhere else but after a quick search the only place where I set the date is in this function.
you can see my own video here 

I used Chrome and IE9 to test and Visual studio 2012 to code 
Telerik.web.ui version is : v.2012.2.912.40 Dev
0
Claudiu Dordea
Top achievements
Rank 1
answered on 04 Oct 2012, 10:04 AM
I found the problem and solved it.
It was the grouping I have a function that updates the grouping on the timeline and at the end of that function I was doing this
dispTimeline.Rebind();
and this line was the problem got it out and it works good now, I wouldn't have found this bug but I noticed that You had no grouping on your timeline so when I got mine out it started working.

So thank you
Tags
Scheduler
Asked by
Claudiu Dordea
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Claudiu Dordea
Top achievements
Rank 1
Share this question
or