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

[Solved] OnClientAppointmentInserting eventArgs

1 Answer 181 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
D
Top achievements
Rank 2
D asked on 28 Apr 2009, 02:39 PM
Hello again,


Still working with the wonders of the scheduler :)
But today we hit a little snag along the road, and would like to know if this is intended behavior or something that was overlooked.

Javascript based error

On with the issue, we are using several radschedulers within our application in order to facilitate in managing our employees workschedules and appointments.
Now one of the criteria of this system is a fast response when inserting new appointments, or when selecting certain timeslots.
At first we achieved this with a few ajaxpanels and stuff like that, however this was not fast enough when inserting/editing appointments.
No one cared that it took 2 seconds to "insert/update" to the database, but what did annoy people was the requirement to postback when opening the advanced view.
So we created our own 'insert' module based off the demos (Using RadDock), however this one also needed to 'postback' to get it's information.
At this time we decided to take a closer look in the different events within the scheduler and found 'OnClientAppointmentInserting', this awnsered our prairs like you would not believe.
A simple event that contains all the information needed to make javascript call the template and fill in the information without ever needing a postback.
During innitial testing the thing behaved like a dream, doing exactly what was writen on the can.
But, here comes the snag...
When setting 'buisiness hours' like the code below the behavior of the eventArgs changed.
With the timelineview below one would imagine clicking the first slot clicked would return: Start 07:00, End 07:30
Instead we were greeted with a rather annoying: Start 00:00, End 00:30

Now we have solved this with some javascript though we would like to know how telerik would 'fix' this.

Below is an example script (Note: You need to substitute the database :) )

Sample code for behavior replication
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SchedulerTest.aspx.cs" Inherits="Datamex.Projects.Saturnus.Pages.SchedulerTest" %> 
 
<%@ Register Assembly="Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" 
  Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title>OnClientAppointmentInserting eventArgs.get_targetSlot().get_startTime() in combination with TimelineView-StartTime</title
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1"
 
    <script type="text/javascript"
 
      function ClientNewAppointment(sender, eventArgs) { 
        // retrieve the scheduler 
        var scheduler = $find('<%= Scheduler.ClientID %>'); 
 
        // retrieve target 
        var Target = eventArgs.get_targetSlot(); 
         
        // Retrieve the 'start time settings' 
        var dayStartTime = scheduler.get_firstDayStart(); 
 
        // Retrieve the current data 
        var dayStartDate = scheduler.get_selectedDate(); 
 
        // calculate the difference 
        var difference = (dayStartTime - dayStartDate); 
         
        // retrieve the start time settings 
        var startTime = new Date(Target.get_startTime()); 
        startTime.setMilliseconds(startTime.getMilliseconds() + difference); 
 
        // retrieve the end time settings 
        var endTime = new Date(startTime); 
        endTime.setMinutes(endTime.getMinutes() + scheduler.get_minutesPerRow()); 
 
        // show the orriginal data + what it should be 
        alert("Data as shown through eventArgs \n\nstart: " + Target.get_startTime() + "\nEnd: " + Target.get_endTime() 
        + "\n\nData as shown after calculations \n\nstart: "+ startTime + "\nEnd: "+ endTime); 
        eventArgs.set_cancel(true); 
      } 
 
    </script> 
 
  </telerik:RadScriptBlock> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <div> 
            <telerik:RadScheduler  
            ID="Scheduler"  
            runat="server"  
            DataSourceID="" 
            DataStartField=""  
            DataEndField=""  
            DataKeyField="" 
            DataSubjectField=""  
            SelectedView="TimelineView"  
            StartInsertingInAdvancedForm="True" 
            GroupBy="Employees"  
            OnClientAppointmentInserting="ClientNewAppointment" 
            > 
            <%-- It fails with this set, when the timelineview starts at a specific time the clientside javascript gets killed --%> 
            <TimelineView GroupingDirection="Vertical" ColumnHeaderDateFormat="HH:mm" NumberOfSlots="27" 
              SlotDuration="00:30:00" StartTime="07:00:00" /> 
            <ResourceTypes> 
              <telerik:ResourceType DataSourceID="EmployeeDataSource" ForeignKeyField="EmployeeID" 
                KeyField="EmployeeID" Name="Employees" TextField="aspnet_User_Details.UserName" /> 
            </ResourceTypes> 
          </telerik:RadScheduler> 
    </div> 
    </form> 
</body> 
</html> 


1 Answer, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 01 May 2009, 07:46 AM
Hi D,

Thank you for reporting this problem. Indeed this is a bug in RadScheduler, which has been fixed with the latest build. You can download it from here and give it a try:
http://www.telerik.com/account/latest-internal-builds.aspx


Best wishes,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Scheduler
Asked by
D
Top achievements
Rank 2
Answers by
Peter
Telerik team
Share this question
or