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

When does RadScheduler SelectedDate get set?

9 Answers 670 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Robert Helm
Top achievements
Rank 1
Robert Helm asked on 10 Feb 2012, 10:36 PM
I've got a RadScheduler and after postback, the SelectedDate gets set somewhere, somehow, back to the current date. The problem is, if the user navigates to another month than the current one, then causes a postback, instead of staying on the current month, it goes back to the initial SelectedDate (today's date).

Thanks for any feedback.

-Bob

9 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 15 Feb 2012, 01:33 PM
Hi Robert,

 I could not reproduce this behavior in none of our demos. Here you can see a video of the my test.

Can you post the code that is connected to the RadScheduler functionality in your scenario so we can reproduce the issue locally?

Kind regards,
Plamen Zdravkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Robert Helm
Top achievements
Rank 1
answered on 15 Feb 2012, 03:52 PM

Thank you for the response, Plamen. Below is the code I used, stripping out some code to keep it simple, using "...comments..." instead.

Basically, my javascript method calls a static page method which calls a class to do the work and then do a postback of the page. At that point, in the ASP.NET Page_Load, the RadScheduler.SelectedDate is still OK, on the proper date that the user navigated to. But when I call a method to rebind my data to the RadScheduler, the RadScheduler.SelectedDate has been reset to today. So the issue seems to be in between the last 2 methods below, PageLoad() and BindScheduler(). I noted those comments with *****.




<telerik:RadScheduler ID="RadScheduler" runat="server" TimeZoneOffset="00:00:00" SelectedView="MonthView"
        TimelineView-UserSelectable="false" OverflowBehavior="Scroll"
        DataKeyField="AppointmentID"
        DataStartField="AppointmentStartTime"
        DataEndField="AppointmentEndTime"
        CustomAttributeNames="...various attributes..."
        StartEditingInAdvancedForm="false"
        StartInsertingInAdvancedForm="False"
        EnableRecurrenceSupport="false"
        AdvancedForm-EnableCustomAttributeEditing="true"               
        AdvancedForm-Enabled="false"
        OnAppointmentDataBound="RadScheduler_AppointmentDataBound"
        OnFormCreating="RadScheduler_FormCreating"              
        OnNavigationCommand="RadScheduler_NavigationCommand"
        OnNavigationComplete="RadScheduler_NavigationComplete"
        OnClientAppointmentContextMenuItemClicked="OnClientAppointmentContextMenuItemClicked"
        OnAppointmentCreated="RadScheduler_AppointmentCreated"                                         
        OnClientAppointmentContextMenu="OnClientAppointmentContextMenuHandler"
        OnClientAppointmentMoveEnd="OnClientMoveEnd" >
    <AdvancedForm EnableCustomAttributeEditing="True" Enabled="False" />
    <MonthView VisibleAppointmentsPerDay="10" ReadOnly="true" />
    <TimelineView UserSelectable="False" />
    <TimeSlotContextMenuSettings EnableDefault="false" />
    ...set up appointment templates, menu, etc...
</telerik:RadScheduler>

<script type="text/javascript">

    function OnClientAppointmentContextMenuHandler(sender, eventArgs) {
        eventArgs.get_domEvent().preventDefault();
    }

    function OnClientMoveEnd(sender, eventArgs) {
        ...set up local variables pulled from eventArgs, etc...
        validateMove(Appointmentid, NewDate, NewStart, NewEnd);
    }

    function validateMove(id, NewDate, NewStart, NewEnd) {
        PageMethods.ValidateMove(id, NewDate, NewStart, NewEnd, onValidateMoveSuccess);
    }

    function onValidateMoveSuccess(result, context, methodName) {
        if (result != "") {
            ...set up local variables W,A,B,X,etc...
            var resp = confirm(result);
            if (resp) {
                __doPostBack('__Page', 'REFRESH|W|A|B|X|')
            }   
        }
    }

</script>

///C# Code behind
[System.Web.Services.WebMethod]
public static string ValidateMove(...arguments passed in...)
{
    //calls a static method on a class to do server work, etc
    return HomePageHelper.RescheduleAppointment(...arguments passed in and out...);
}

protected void Page_Load(object sender, EventArgs e)
{
    ScriptManager.GetCurrent(this.Page).EnablePageMethods = true; //38095
              
    if (!IsPostBack) {   
        BindScheduler();
    }
    else {

        string eventArg = Request["__EVENTARGUMENT"];
        if (eventArg.Contains("REFRESH"))
        {
            if (eventArg.Split('|')[1].Contains("W"))    //Scheduling drag/drop dialog result
            {
                return HomePageHelper.RescheduleAppointment(...arguments passed in and out...);
            }

            ***** At this point, the RadScheduler.SelectedDate is OK, meaning it is still
            set to whatver month/day the user had navigated to *****

            BindScheduler();

        }       
    }
}    
               
private void BindScheduler()
{
    ***** By the time I get here, the RadScheduler.SelectedDate has already been
    set back to the current day ***** 
 
    ApptList = FillList(...arguments passed in, etc...) //ApptList is a list of appointments    

    RadScheduler.DataSource = ApptList;
}

       
       
       
       
       
       
       
       
       
       
       
       
       

0
Robert Helm
Top achievements
Rank 1
answered on 15 Feb 2012, 03:54 PM
Also, I may have a workaround that I am still testing. That's simply setting the RadScheduler.SelectedDate = RadScheduler.SelectedDate in the Page_Load() right before I call BindScheduler() to rebind the data. I'm still testing that though.
0
Accepted
Plamen
Telerik team
answered on 20 Feb 2012, 10:51 AM
Hello Robert,

 
I will recommend you to refer to our Bind To List demo, where the a similar scenario is described and the selected date is working properly. 

Another way to handle this issue is to pass the selected date in the BindScheduler method as a parameter and reset it inside it once again.

Hope this will be helpful.

Regards,
Plamen Zdravkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Robert Helm
Top achievements
Rank 1
answered on 27 Feb 2012, 08:14 PM
Thanks Plamen. Passing the selected date into the BindScheduler method works fine.
 
0
Sandy
Top achievements
Rank 1
answered on 11 Oct 2013, 06:37 PM
Hi,

I am getting the current date into Appscheduler.slecteddate.

please help me.
below is my Code.


public void AppScheduler_AppointmentClick(object sender, SchedulerEventArgs e)
        {
            

            DateTime SelectedDate = AppScheduler.SelectedDate;
            IBopAppointmentService dt = ServiceFactory.Create<BopAppointmentService>();
            List<BOPAppointmentVWDTO> lstBopAppointment = dt.GetAppointmentsByDate(SelectedDate).ToList();
}
0
Plamen
Telerik team
answered on 14 Oct 2013, 10:37 AM
Hi Sandy,

 
I have tested the provided code and it worked as expected at my side. I will recommend you to check whether you are setting the SelectedDate somewhere else in your code behind that may affect the result in the click event.

Regards,
Plamen
Telerik
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 the blog feed now.
0
Venkatesh
Top achievements
Rank 1
answered on 03 Sep 2014, 02:21 AM
Hi,

Ive a similar issue. Below is my code

DateTime t = RadScheduler1.SelectedDate;
DateTime t1 = RadScheduler1.SelectedDate.AddDays(30);
0
Plamen
Telerik team
answered on 05 Sep 2014, 08:09 AM
Hello,

It is not quite clear what you are trying to achieve with the code provided but you can get the Selected Date of RadScheduler on page load for example as in the code below:
protected void Page_Load(object sender, EventArgs e)
{
    Response.Write(RadScheduler1.SelectedDate);
    RadScheduler1.SelectedDate = DateTime.Today;
}


Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
Robert Helm
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Robert Helm
Top achievements
Rank 1
Sandy
Top achievements
Rank 1
Venkatesh
Top achievements
Rank 1
Share this question
or