How can I stop and start timer

2 posts, 0 answers
  1. BET
    BET avatar
    9 posts
    Member since:
    Feb 2013

    Posted 04 Feb 2013 Link to this post

    How can I stop timer(in other words stop browser refresh/page refresh), while dragging a task from RadGrid to RadScheduler and how can I start timer(in other words start browser refresh/page refresh), after the task is dropped.
    My drag and drop is similar to this demo
    http://demos.telerik.com/aspnet-ajax/scheduler/examples/draganddropintegration/defaultcs.aspx?product=scheduler

    This is my code for RadScheduler:
    <telerik:RadScheduler ID="rsTicketsSchedule" runat="server" AllowInsert="False" DisplayDeleteConfirmation="False"
                                Localization-HeaderToday="Today" EnableCustomAttributeEditing="True" EnableDescriptionField="True"
                                Height="100%" EnableExactTimeRendering="true" EnableViewState="true" OverflowBehavior="Scroll"
                                ShowAllDayRow="false" OnAppointmentDataBound="TicketsSchedule_AppointmentDataBound"
                                OnNavigationComplete="rsTicketsSchedule_NavigationComplete" OnNavigationCommand="rsTicketsSchedule_NavigationCommand"
                                OnTimeSlotCreated="rsTicketsSchedule_TimeSlotCreated" OnAppointmentUpdate="onApptUpdate"
                                OnClientAppointmentDoubleClick="rsClientAppointmentDoubleClick" OnClientAppointmentClick="singleClick"
                                OnClientAppointmentContextMenu="CheckTimerStatus" OnClientAppointmentContextMenuItemClicked="handleClick"
                                OnClientFormCreated="ClientFormCreated" OnDataBound="rsTicketsSchedule_DataBound"
                                OnClientAppointmentMoveEnd="AppointmentMoved" OnClientAppointmentDeleting="OnClientAppointmentDeleting"
                                OnClientAppointmentMoveStart="StopTimer" 
                                CustomAttributeNames="HasAttachment"    DataReminderField="Reminder" OnClientAppointmentEditing= "StopTimer"    >
                               <AppointmentTemplate>
                                     <div>
                                             <asp:Panel ID="RecurrencePanel" CssClass="rsAptRecurrence" runat="server" Visible="false" />
                                             <asp:Panel ID="RecurrenceExceptionPanel" CssClass="rsAptRecurrenceException" runat="server"
                                                  Visible="false" />
                                           <%--  <asp:Panel ID="ReminderPanel" CssClass="rsAptReminder" runat="server" Visible="true" />--%>
                                             <div id="ApptImageDiv" style="text-align:right; position:absolute; width:95%;" >
                                                 <asp:Image ID="ApptAttachmentImg" runat="server"  Width="16px" Height="17px" style=" margin-right:5px; background:url(img/sprite-alpha.png)-166px -34px no-repeat; background-position: -98px -66px; border:transparent; " 
                                                               Visible='<%# String.IsNullOrEmpty(Container.Appointment.Attributes["HasAttachment"])? false : Boolean.Parse(Container.Appointment.Attributes["HasAttachment"]) %>'
                                                  />
                                              </div>
                                             <%#Eval("Subject") %>     
                                      
                                      </div>
                                </AppointmentTemplate    >
                            
                                <AppointmentContextMenus     >
                                </AppointmentContextMenus>
                                <DayView UserSelectable="True" GroupBy="TechName" GroupingDirection="Horizontal" />
                                <WeekView UserSelectable="True" GroupBy="TechName" GroupingDirection="Vertical" />
                                <MonthView UserSelectable="True" GroupBy="TechName" GroupingDirection="Vertical" />
                                <TimelineView ColumnHeaderDateFormat="h:mm tt" GroupingDirection="Vertical" HeaderDateFormat="MM/dd/yyyy h:mm tt"
                                    NumberOfSlots="21" SlotDuration="00:30:00" StartTime="08:00:00" />
                                <AdvancedForm EnableCustomAttributeEditing="True" Modal="True" />
                                <ResourceTypes>
                                    <telerik:ResourceType Name="TechName" />
                                    <telerik:ResourceType Name="TicketState" />
                                </ResourceTypes>
                                <Reminders Enabled="true"></Reminders>
                                    
                            </telerik:RadScheduler>

    Thanks for your help in advance

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 07 Feb 2013 Link to this post

    Hello,

    I would recommend using the asp:Timer control to refresh your page and rebind both the RadScheduler and RadGrid controls. Stopping and starting the timer control in specific client-side event handler could achieve the desired functionality. Please find attached a sample project that implements the described scenario.
    I would summarize and highlight in the code below how you can stop and start the time in order to fit your requirement.
    //markup code

    <asp:Timer ID="Timer1" runat="server" Interval="6000" Enabled="true" OnTick="Timer1_Tick"></asp:Timer>
    .....
     <telerik:RadGrid runat="server" ID="RadGrid1" .......>
                        <ClientSettings AllowRowsDragDrop="True">
                           ...
                       <ClientEvents OnRowDropping="rowDropping" OnRowDblClick="onRowDoubleClick" OnRowDragStarted="dragStarted"></ClientEvents>
                        </ClientSettings>
    ......
    </telerik:RadGrid>
    //JavaScript
    function rowDropping(sender, eventArgs) {
        // Fired when the user drops a grid row
        var htmlElement = eventArgs.get_destinationHtmlElement();
        var scheduler = $find('<%= RadScheduler1.ClientID %>');
        var timer = $find("<%=Timer1.ClientID %>");
        timer._startTimer();
       .........
    }
     
    function dragStarted(sender, args) {
        var timer = $find("<%=Timer1.ClientID %>");
        timer._stopTimer();
         
    }
    //code behind
    protected void Timer1_Tick(object sender, EventArgs e)
        {
            RadScheduler1.DataBind();
            RadGrid1.DataBind();
        }

    Here you could find more information about the asp:Timer control.

    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.
Back to Top