Scheduler Selected View and date range is reset on an F5 Refresh

6 posts, 0 answers
  1. Michael Hunt
    Michael Hunt avatar
    42 posts
    Member since:
    Aug 2009

    Posted 07 Oct 2010 Link to this post

    Hi,

    I'm using the 2010.2.826.35 version of the ASP.NET for AJAX controls.  I'm new to the Scheduler, and assume this is a simple question but couldn't find a KB article or forum post that answers it.

    My Scenario:
    - When my page loads, the Scheduler shows the current month as expected (it is in MonthView).
    - Then I scroll to a new month (or even switch to week view and scroll to any week).
    - If I hit F5 to do a page refresh in the browser, the Scheduler again shows the current month.

    What I want it to do, is continue to show the correct timeline and date range that I was currently looking at.

    Q.  What is the recommended way of doing that?

    Do I store the SelectedView type and the date range in hidden fields, and read them and set the appropriate properties of the Scheduler?

    Thanks,
    Michael
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 13 Oct 2010 Link to this post

    Hello Michael Hunt,

    Please accept my apologies for the late reply.

    Yes, this is expected behavior that when you refresh a page or redirect from another page  RadScheduler returns to initial SelectedView or SelectedDate.

    One possible way to store them is to use a hidden field as you suggested. Other option is to store them in a cookie. Here's an example:

    you can subscribe to the NavigationComplete event to store the SelectedDate of the scheduler. Here's the code:

    Copy Code
    protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
        {
            if (e.Command == SchedulerNavigationCommand.NavigateToSelectedDate)
            {
                HttpCookie cookie = new HttpCookie("selectedDate");
                cookie.Value = RadScheduler1.SelectedDate.ToString();
                Response.SetCookie(cookie);
            }
        }

    then you can read the cookie in Page_PreRender event:

    Copy Code
    protected void Page_PreRender(object sender, EventArgs e)
        {
            if (Request.Cookies["selectedDate"] != null)
            {
                RadScheduler1.SelectedDate = DateTime.Parse(Request.Cookies["selectedDate"].Value);
            }
        }

    Please let me know if this was helpful.

    Best Regards,
    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
  3. Michael Hunt
    Michael Hunt avatar
    42 posts
    Member since:
    Aug 2009

    Posted 12 Nov 2010 Link to this post

    Actually, I just getting back into working on this, and the proposed solution isn't exactly what I want.

    I want to be able to set the set the visible start and end dates on the scheduler.  The scenario is this:

      User is looking at Month View, for the Month of November.
      User navigates to October and the scheduler displays Sept 27th - Nov 5th (since it displays the entire first and last week of October, it also displays the end of Sept and the beginning of November).
      User navigates away from the scheduler page (at which time I save their SelectedView and Visible Start and End Dates).
      User then navigates back to the Scheduler page.

    In server side code, I set the SelectedView to Month and the SelectedDate to September 27th.

    PROBLEM:
    Now the scheduler displays the month of September.
    But I wanted to display the month of October.

    It's strange that I can set the SelectedView, but I can't set the start and end date range I want to display.  Seems like a useful feature.

    How can I accomplish this?

    Thanks,
    Michael.
  4. Michael Hunt
    Michael Hunt avatar
    42 posts
    Member since:
    Aug 2009

    Posted 12 Nov 2010 Link to this post

    Please disregard my previous post.  I've figured it out.  For month view, I'll just make sure and save the first day of the current month I've viewing, as my selected date...

    Thanks.
  5. Sandy
    Sandy avatar
    26 posts
    Member since:
    Mar 2012

    Posted 07 Mar 2012 Link to this post

    Hi
    I am using Rad Scheduler.I set Rad scheduler default view to Month.when I select in scheduler to day view or week view and then navigate to another page and i come bak it is loading as month view only how can I get the view which i was in when i was leaving the page.
    Thank you.
  6. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 12 Mar 2012 Link to this post

    Hello Sandy,

     
    I have tested the code that was posted by Veronica when the page is redirected and then used the back button and also refreshed the page with F5, but everything worked as expected. I am attaching a working sample that reproduces this behavior. Would you please explain how is your case different?

    Kind regards,
    Plamen Zdravkov
    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.
Back to Top