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

Refresh On button Click-Rad scheduler

8 Answers 402 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
smith spd
Top achievements
Rank 1
smith spd asked on 06 Aug 2010, 08:45 PM
Hello Telerik Team,

I need to achieve a functionality to refresh the scheduler on a button click event.
The button should exist as a link button on the scheduler.I am using sharepoint list as the datasource
Could you provide some pointers on this.

Thank you
Smith

 

8 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 09 Aug 2010, 03:59 PM
Hi smith,

You can call RadScheduler's Rebind() method in your button click event handler to refresh the control.


Peter
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
0
smith spd
Top achievements
Rank 1
answered on 09 Aug 2010, 04:31 PM

Hello Telerik Team,

Thank you for the response.where do i need to place the link button so that it appears
on the rad scheduler.Can i have a sample of it.
I appreciate your response.

Thank you
Smith

0
Peter
Telerik team
answered on 10 Aug 2010, 01:16 PM
Hi Smith,

Currently, RadScheduler does not have Header template, but we plan to implement this feature, which would allow you to achieve your goal easily. Please, excuse us for this temporary limitation of RadScheduler.


Greetings,
Peter
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
0
smith spd
Top achievements
Rank 1
answered on 10 Aug 2010, 08:00 PM
Hello Telerik team,

Thank you for the response.

I have used a asp:panel and kept one link button(for refresh) in that and it appears on the scheduler.
I did the following way and its  working

protected void lnkRefresh_Click(object sender, EventArgs e)
         {
            

 

callRadSchedulerMethod();

 

RadScheduler1.Rebind();

         }


Thank you
Smith

 

0
FRANK
Top achievements
Rank 1
answered on 10 Feb 2012, 04:28 PM
Hi Smith,

I am trying to implement same functionality on button click but it's not refreshing the scheduler while datatable gets data as per filter. I get the following error on button click when I use Ajaxmanager within Ajaxpanel: 
Microsoft JScript runtime error: Sys.InvalidOperationException: A control is already associated with the element.

The above error goes away whan use Ajaxmanager outside of Ajaxpanel but still does not refresh Scheduler Data. 

It works fine when I navigate ( next, previous arrow) through Scheduler itself.  Would you mind sharing the code how you did it? Here is my code details: 

Code Behind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        SetConnection()

        If IsPostBack = False Then
            RadSchCalendar.SelectedView = SchedulerViewType.MonthView
            FillYear()
            FillDepartments()
            FillDeptUser()
            GetAppointments("","","",False)
        End If
End Sub

 Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest

        Dim dateClicked As String = e.Argument
        Dim seps As Char() = {"/"}
        Dim dateArray As String() = dateClicked.Split(seps, StringSplitOptions.RemoveEmptyEntries)
        Dim selectedDate As New DateTime(Int32.Parse(dateArray(2)), Int32.Parse(dateArray(0)), Int32.Parse(dateArray(1)))
        RadSchCalendar.SelectedDate = selectedDate
        RadSchCalendar.SelectedView = SchedulerViewType.TimelineView

    End Sub

    Protected Sub RadSchCalendar_NavigationComplete(sender As Object, e As SchedulerNavigationCompleteEventArgs)
        Dim strYear As String = String.Empty
        Dim strMonth As String = String.Empty
        Dim strDate As String = String.Empty

        strYear = Year(RadSchCalendar.SelectedDate)
        strMonth = Month(RadSchCalendar.SelectedDate)

        If strYear <> "" Then
            Dim intIndex As Integer = radcboYear.FindItemIndexByValue(strYear)
            If radcboYear.Items.Count > 0 Then
                radcboYear.SelectedIndex = intIndex
            End If
        End If
        If RadSchCalendar.SelectedView = SchedulerViewType.MonthView Then
            strDate = ""
        ElseIf RadSchCalendar.SelectedView = SchedulerViewType.TimelineView Then
            strDate = RadSchCalendar.SelectedDate.ToString("MM/dd/yyyy")
        End If
        GetAppointments(strYear, strMonth, strDate, True)
    End Sub

 Protected Sub RadSchCalendar_AppointmentCreated(sender As Object, e As AppointmentCreatedEventArgs)

        If e.Appointment.Attributes("ColorCode") <> "" Then 'Bunti Singh
            e.Appointment.BackColor = System.Drawing.ColorTranslator.FromHtml(e.Appointment.Attributes("ColorCode"))
        End If
 End sub

Private

 

 

Sub RadButton1_Click(sender As Object, e As System.EventArgs) Handles RadButton1.Click

    GetAppointments("","","",True)

 

End Sub

 


Private

 

 

Sub GetAppointments(ByVal strYear As String, ByVal strMonth As String, ByVal strDate As String, ByVal blnReBinding As Boolean)

 

        Dim dtTable As New DataTable
        Dim strDeptCode as string = get value from department radcombo.
        dtTable = _DbxCon.SpToDataTable("procGetCalendarData", strDeptCode)
        Try
            ' datatable returns the data as per department. 
            RadSchCalendar.DataSource = dtTable
            If blnReBinding = True Then
                RadSchCalendar.Rebind()
            Else
                RadSchCalendar.DataBind()
            End If
        Catch ex As SqlException
            lblError.Text = ex.Message
        End Try
End Sub

======================== User Control Code=================

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="VacationCalendar.ascx.vb" Inherits="DotNet.VacationCalendar" %>

<div style="width:100%;">
<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" >
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadSchCalendar" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="btnView">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadSchCalendar" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

 

 

 

 

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Default" BackgroundPosition="Center" EnableSkinTransparency="true"  runat="server" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID= "RadAjaxLoadingPanel1" >
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />   
    <table border="0" cellpadding="0" cellspacing="2" style="width:100%;">
        <tr>
           <td colspan = "7">
               <asp:Label ID="lblError" runat="server" Text="" ForeColor="Red" ></asp:Label>
           </td>
        </tr>
        <tr>
           <td width = "80px" align = "right" ><b>Year :</b></td>
           <td width = "80px" align= "left">
               <telerik:radcombobox ID="radcboYear"
                    Skin="Office2007"
                    Width="60px" 
                    runat="server"
                    MarkFirstMatch="True"
                    OnClientSelectedIndexChanged="function(){DisplayRefreshMessage('D');}">
               </telerik:radcombobox> 
           </td>
           <td width = "100px" align = "right" ><b>Department :</b></td>
           <td width = "220px" align= "left">   
               <telerik:RadComboBox ID="radcboDept" runat="server" Skin = "Office2007"  
               CheckBoxes="true" EnableCheckAllItemsCheckBox="true" Width="210px"
               MarkFirstMatch = "true"
               OnClientSelectedIndexChanged="function(){DisplayRefreshMessage('D');}">
               </telerik:RadComboBox>
           </td>
           <td width = "100px" align = "right" ><b>Employee :</b></td>
           <td width = "220px" align= "left">
                <telerik:radcombobox ID="radcboUser"
                Skin="Vista"
                Width="215px" 
                runat="server"
                MarkFirstMatch="True"
                OnClientSelectedIndexChanged="function(){DisplayRefreshMessage('D');}">
                </telerik:radcombobox> 
           </td>
           <td width = "70px"> 
               <telerik:RadButton ID="RadButton1" runat="server" Text="View" width="60px"> </telerik:RadButton>
           </td>
        </tr>
    </table>
    <table>   
        <tr>
           <td >
            <telerik:RadScheduler ID="RadSchCalendar" runat="server"
                ShowFullTime ="false"
                ShowAllDayRow = "true"
                ShowHoursColumn= "false"
                WorkDayStartTime="00:00:00"  
                WorkDayEndTime="11:59:59"
                ShowFooter = "false"
                Readonly = "true"
                Height= "700px"
                RowHeight = "20px" 
                DataStartField="DateFrom"
                DataEndField="DateTo"        
                DataKeyField="RecID"
                DataSubjectField="Subject"
                CustomAttributeNames="ColorCode"
                MonthView-ShowResourceHeaders="true"
                MonthView-ShowDateHeaders="true"
                Onappointmentcreated="RadSchCalendar_AppointmentCreated"        
                Ondatabound="RadSchCalendar_DataBound" Skin="Forest"
                OnNavigationComplete = "RadSchCalendar_NavigationComplete">
                <TimelineView UserSelectable= "true" NumberOfSlots="1" />
                <WeekView UserSelectable= "true" />
                <DayView UserSelectable= "False" />
                <MonthView VisibleAppointmentsPerDay="5" AdaptiveRowHeight="true" />     
            </telerik:RadScheduler>
        </td>
        </tr>
    </table>
</telerik:RadAjaxPanel>
<br />
<span style="text-align: center; width: 100%;">
</span>
<br />       
</div>

 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
 <Scripts>
   <%--Needed for JavaScript IntelliSense in VS2010--%>
   <%--For VS2008 replace RadScriptManager with ScriptManager--%>
   <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
 </Scripts>

<script type="text/javascript">

    function pageLoad(sender, args) {
        $ = $telerik.$;
        var a = $(".rsDateHeader").click(function (e) {

            $(this)[0].title
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest($(this)[0].title);
            e.stopPropagation();
            e.preventDefault();
        });

        var more = $(".rsShowMore").click(function (e) {
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest($(this.parentElement).find(" .rsDateHeader")[0].title);
            e.stopPropagation();
            e.preventDefault();
        });
    }
   
    //Set the label message for change of drop down.
    // strflag = 'D' means display message
    //           'H' hide message
    function DisplayRefreshMessage(strflag) {
        var lblMes = document.getElementById('<%= lblError.ClientID %>');
        if (strflag == 'D') {
            lblMes.innerText = "*** Please press View button to refresh data. ***";
        }
        else {
            lblMes.innerText = "";
        }
        return
    }

</script>
</telerik:RadScriptBlock>

=======================================================
Thanks in advance,
-Ram 
0
FRANK
Top achievements
Rank 1
answered on 10 Feb 2012, 05:37 PM

Never Mind, I solved my problem by using the following code after Rebind.

RadSchCalendar.SelectedDate = Convert.ToDateTime(dtTable.Rows(0)("DateTo"))

thanks,
-Ram

 

 

 

  

0
Santosh
Top achievements
Rank 1
answered on 30 Jul 2012, 06:15 PM
Hi,
I am using Rad Schedular on ASCX (user control) page in MVC project and i want to Refresh only Rad Schedular on drop down changed
 not entire page load or referesh.but when i changed the drop down it's refresh the schedular but data are not changed in schedular.the change only happen when whole page are reload. i am try to change minutesperrow of schedular.
i am using following code
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="MinutesPerRow">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="MyScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="HoursColumn" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" />
<asp:DropDownList ID="MinutesPerRow" AutoPostBack="true" runat="server">
<asp:ListItem Value="5" Text="10"></asp:ListItem>
<asp:ListItem Value="15" Text="30" ></asp:ListItem>
<asp:ListItem Value="30" Text="60"></asp:ListItem>
</asp:DropDownList><
telerik:RadScheduler ID="MyScheduler1" runat="server" AllowDelete="true"
SelectedView="WeekView" StartInsertingInAdvancedForm="true" ShowHeader="false"
StartEditingInAdvancedForm="true" AllowEdit="true" OnClientDataBound="OnClientDataBound"

This code isworking fine with.aspx page but problem happen on ascx page.
please help me
0
Peter
Telerik team
answered on 02 Aug 2012, 08:50 AM
Hello,

To change the minutes per row for RadScheduler requires server-side event handling, which is not possible in MVC.

All the best,
Peter
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.
Tags
Scheduler
Asked by
smith spd
Top achievements
Rank 1
Answers by
Peter
Telerik team
smith spd
Top achievements
Rank 1
FRANK
Top achievements
Rank 1
Santosh
Top achievements
Rank 1
Share this question
or