Thanks for any feedback.
-Bob
9 Answers, 1 is accepted
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?
Plamen Zdravkov
the Telerik team
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;
}
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.
Plamen Zdravkov
the Telerik team
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();
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.
Plamen
Telerik
Ive a similar issue. Below is my code
DateTime t = RadScheduler1.SelectedDate;
DateTime t1 = RadScheduler1.SelectedDate.AddDays(30);
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.