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

Refreshing RadScheduler Issue

5 Answers 571 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
julian Welby Everard
Top achievements
Rank 1
julian Welby Everard asked on 10 Mar 2009, 03:14 PM

Current setup

I have a master page which contains a user control, which has a raddropdown and a listview control.

When the user selects a user in the dropdown, the selected user is placed in the list view (selected users). This then raises an event that an Item has been added to selected users control.

There are properties on the master page which return a list(of x) for the selected users.

The RadScheduler is to display appointments for each of the user selected.

This currently is done by adding the following code

        Dim a As List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name)
        a = CType(Page.Master, ISession).SelectedConsultants
        Dim rt As New Telerik.Web.UI.ResourceType()
        rt.DataSource = a
        rt.KeyField = "ContactID"
        rt.TextField = "ContactName"
        rt.Name = "Contacts"
        rt.ForeignKeyField = "Contact"
        RadScheduler1.ResourceTypes.Clear()
        RadScheduler1.ResourceTypes.Add(rt)
        RadScheduler1.GroupBy = "Contacts"

This all works fine so far. BUT...

When I add a new user to the list, and reload the control (all ajaxy) type posts. The RadScheduler does not render. If I click on week display and then back to daily the updated users do display.

Is there any way of forcing the re-render/update of the RadScheduler, I’ve removed it from the page and re-added with no luck.

 

Julian

 

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Mar 2009, 12:48 PM
Hello julian Welby Everard,

Please try calling the Rebind method of RadScheduler. It should repopulate the scheduler control.

Regards,
Albert
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.
0
julian Welby Everard
Top achievements
Rank 1
answered on 11 Mar 2009, 02:44 PM
Hi

I've added the rebind methord to the page and still no luck, the control is not re-rendering.
also I have added a javascript rebind as per examples on this forum and the control is not re-rendering.

I have noticed that the data is bound as when i click to weekely view and back again the data is displayed

so I need a way of forceing a re-render of the control.

Julian
0
Atanas Korchev
Telerik team
answered on 11 Mar 2009, 02:47 PM
Hello julian Welby Everard,

Are you using RadAjax in your application. If yest could you verify that it is configured to update RadScheduler? I guess the scheduler is being rebound but is not updated on the client-side.

Greetings,
Albert
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.
0
julian Welby Everard
Top achievements
Rank 1
answered on 11 Mar 2009, 03:17 PM
Yes I think so... (im new to this)

ill try and summiries my code a bit.

page.master
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnResponseEnd="refreshScheduler" > 
        <div> 
            <telerik:RadScriptManager runat="server">  
            </telerik:RadScriptManager> 
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Web20" VisibleStatusbar="False" 
                Modal="True" Behaviors="Close, Move" Title="Search" Width="450px" Height="300px" InitialBehaviors="None" Left="" Style="display: none;" Top="" /> 
            <div> 
                <telerik:RadSplitter ID="RadSplitter1" runat="server" SplitBarsSize="" Width="100%" 
                    Height="100%" ResizeMode="EndPane">  
                    <telerik:RadPane ID="RadPane1" runat="server" Scrolling="None" MinWidth="100" MaxWidth="175" 
                        Width="175px">  
                        <asp:HiddenField ID="SessionID" runat="server"></asp:HiddenField> 
                        <telerik:RadPanelBar ID="MenuPanel" runat="server" Skin="Safe" EnableEmbeddedSkins="false">  
                            <CollapseAnimation Duration="100" Type="None" /> 
                            <Items> 
                                <telerik:RadPanelItem runat="server" Text="Calendar" Value="Calendar" ImageUrl="~/Images/Icons/calendar.png">  
                                    <Items> 
                                        <telerik:RadPanelItem> 
                                            <ItemTemplate> 
                                                <telerik:RadCalendar ID="DiaryCal" runat="server" Font-Names="Arial,Verdana,Tahoma" 
                                                    Skin="Office2007" ForeColor="Black" Style="border-color: #ececec" AutoPostBack="True" 
                                                    CultureInfo="English (United Kingdom)" SelectedDate="" ViewSelectorText="x">  
                                                </telerik:RadCalendar> 
                                                <uc1:ajaxConsultantDropdown ID="ajaxConsultantDropdown1" runat="server" ComboBoxWidth="130px" DropBoxWidth="350px" /> 
                                            </ItemTemplate> 
                                        </telerik:RadPanelItem> 
                                    </Items> 
                                </telerik:RadPanelItem> 
                                <telerik:RadPanelItem runat="server" Text="Tasks" Value="Tasks" ImageUrl="~/Images/Icons/contract_Icon.png" /> 
                                <telerik:RadPanelItem runat="server" Text="Scratchpad" ImageUrl="~/Images/Icons/report.png" /> 
                                <telerik:RadPanelItem runat="server" Text="Mail" Value="Mail" ImageUrl="~/Images/Icons/email_open.png">  
                                    <Items> 
                                        <telerik:RadPanelItem runat="server" Text="Inbox" NavigateUrl="Mail.aspx">  
                                        </telerik:RadPanelItem> 
                                        <telerik:RadPanelItem runat="server" Text="Outbox" NavigateUrl="Mail.aspx">  
                                        </telerik:RadPanelItem> 
                                        <telerik:RadPanelItem> 
                                            <ItemTemplate> 
                                                <asp:Button ID="Button1" runat="server" Text="Search" UseSubmitBehavior="false" OnClientClick="ShowMessage();return false;" /> 
                                            </ItemTemplate> 
                                        </telerik:RadPanelItem> 
                                    </Items> 
                                </telerik:RadPanelItem> 
                            </Items> 
                            <ExpandAnimation Duration="100" Type="None" /> 
                        </telerik:RadPanelBar> 
                    </telerik:RadPane> 
                    <telerik:RadSplitBar ID="RadSplitBar1" runat="server" CollapseMode="None" /> 
                    <telerik:RadPane ID="RadPane2" runat="server">  
                        <asp:ContentPlaceHolder ID="cph" runat="server">  
                        </asp:ContentPlaceHolder> 
                    </telerik:RadPane> 
                </telerik:RadSplitter> 
            </div> 
        </div> 
    </telerik:RadAjaxPanel> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" > 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="DiaryCal">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="ajaxConsultantDropdown1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadScheduler1" > 
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting>              
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
 
page.master.vb
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
        Dim menu As Telerik.Web.UI.RadPanelBar = Me.FindControl("MenuPanel")  
        Dim panel As Telerik.Web.UI.RadPanelItem = menu.Items.FindItemByValue("Calendar")  
        Dim dropDown As ISafeActionTriggers = CType(panel.Controls(0).FindControl("ajaxConsultantDropdown1"), ISafeActionTriggers)  
 
        If Not Page.ClientScript.IsClientScriptBlockRegistered("RadScheduler1Refresh") Then  
            Dim sb As New StringBuilder  
            sb.AppendLine("function refreshScheduler()")  
            sb.AppendLine("{")  
            sb.AppendLine(String.Format("var ajaxManager = $find('{0}');", RadAjaxManager1.ClientID))  
            sb.AppendLine("if (ajaxManager != null)")  
            sb.AppendLine("{")  
            sb.AppendLine("ajaxManager.ajaxRequest('RebindScheduler');")  
            sb.AppendLine("}")  
            sb.AppendLine("}")  
            Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "RadScheduler1Refresh", sb.ToString, True)  
        End If  
 
    End Sub  
.  
.  
.  
    Public ReadOnly Property ConsultantDropdown() As System.Web.UI.UserControl Implements ISession.ConsultantDropdown  
        Get  
            Dim menu As Telerik.Web.UI.RadPanelBar = Me.FindControl("MenuPanel")  
            Dim panel As Telerik.Web.UI.RadPanelItem = menu.Items.FindItemByValue("Calendar")  
            Return panel.Controls(0).FindControl("ajaxConsultantDropdown1")  
        End Get  
    End Property  
.  
.  
.  
    Public ReadOnly Property SelectedConsultants() As List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name) Implements ISession.SelectedConsultants  
        Get  
            Dim listOfConsultants As List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name)  
            Dim consultantControl As Control = MenuPanel.FindItemByValue("Calendar").Controls(0).FindControl("ajaxConsultantDropdown1")  
            If consultantControl IsNot Nothing Then  
                listOfConsultants = CType(consultantControl, IListSource).GetList()  
                If listOfConsultants Is Nothing Then  
                    listOfConsultants = New List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name)  
                End If  
                If listOfConsultants.Count = 0 Then  
                    listOfConsultants.Add(New Safe.CRM.DAL.BusinessObjects.Contact_Name(Me.mySession.ContactID, "Julian Welby-Everard"))  
                    listOfConsultants.Add(New Safe.CRM.DAL.BusinessObjects.Contact_Name(New Guid("1D459F7E-5A4F-4F6B-87B9-7099B4F4CEDF"), "Martin Cady"))  
                End If  
            Else  
                listOfConsultants = New List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name)  
                listOfConsultants.Add(New Safe.CRM.DAL.BusinessObjects.Contact_Name(Me.mySession.ContactID, "Julian Welby-Everard"))  
                listOfConsultants.Add(New Safe.CRM.DAL.BusinessObjects.Contact_Name(New Guid("1D459F7E-5A4F-4F6B-87B9-7099B4F4CEDF"), "Martin Cady"))  
            End If  
            Return listOfConsultants  
        End Get  
    End Property 
now some usercontrols that i have made
ajaxConsultantDropdown.ascx
<asp:Panel runat="server" ID="Panel1" CssClass="consultantDropdown" > 
    <asp:Panel ID="Panel2" runat="server" style="float:left;" > 
        <asp:Panel ID="Panel3" runat="server" style="float:left;" > 
            <telerik:radcombobox id="RadComboBox1" runat="server" allowcustomtext="True" onitemsrequested="RadComboBox1_ItemsRequested" 
                enableloadondemand="True" highlighttemplateditems="True" onitemdatabound="RadComboBox1_ItemDataBound" 
                skin="Office2007" autopostback="true"   
                showmoreresultsbox="true">  
                <CollapseAnimation Type="OutQuint" Duration="200" /> 
                <HeaderTemplate> 
                    <ul> 
                        <li class="consultantDropdownCol" >Forename</li> 
                        <li class="consultantDropdownCol" >Surname</li> 
                    </ul>   
                </HeaderTemplate> 
                <ItemTemplate> 
                    <ul> 
                        <li class="consultantDropdownCol" ><%#Trim(DataBinder.Eval(Container.DataItem, "Forename"))%></li>  
                        <li class="consultantDropdownCol" ><%#Trim(DataBinder.Eval(Container.DataItem, "Surname"))%></li>  
                    </ul> 
                </ItemTemplate> 
                <FooterTemplate /> 
            </telerik:radcombobox> 
        </asp:Panel>   
        <asp:Panel ID="Panel4" runat="server" style="float:left;" > 
            <asp:Button ID="btnAdd" runat="server" CausesValidation="False" Text="Add" OnClick="btnAdd_Click" UseSubmitBehavior="False" CommandName="addItem" /> 
        </asp:Panel>   
    </asp:Panel>   
    <br /> 
    <asp:ListView runat="server" ID="lstConsultants" > 
        <LayoutTemplate> 
            <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> 
        </LayoutTemplate> 
        <ItemTemplate> 
            <asp:Panel runat="server" style="clear:both" > 
                <asp:HiddenField runat="server" ID="contactID" Value='<%#Bind("ContactID")%>' /> 
                <asp:Label runat="server" ID="fullName" Text='<%#Bind("ContactName") %>' Width='<%# getTextWidth() %>' style="white-space:nowrap" /> 
                <asp:ImageButton runat="server" ID="btnDelete" ImageUrl="~/Images/Icons/cross.png" OnClick="btnDelete_Click" AlternateText="Remove from list" CommandName="deleteItem" />   
            </asp:Panel>   
        </ItemTemplate> 
    </asp:ListView> 
</asp:Panel> 
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" /> 
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="btnAdd" > 
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="btnAdd" /> 
                <telerik:AjaxUpdatedControl ControlID="lstConsultants" /> 
                <telerik:AjaxUpdatedControl ControlID="RadComboBox1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        <telerik:AjaxSetting AjaxControlID="btnDel">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="btnDel" /> 
                <telerik:AjaxUpdatedControl ControlID="lstConsultants" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        <telerik:AjaxSetting AjaxControlID="RadAjaxPanel1">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManagerProxy>
 
There is a lot of Code bhind on this, this control works, it created and maitains the ListView and methords return data collections ie List(of ....)

Diary.ascx
    <table style="width: 100%;">  
        <tr> 
            <td> 
                <telerik:RadScheduler  
                    ID="RadScheduler1"   
                    runat="server"   
                    DataEndField="EndDate"   
                    DataKeyField="ActivityID" 
                    DataSourceID="odsMyDiary"   
                    SelectedDate='<%# DayToShow() %>'   
                    DataStartField="ActivityCompleteBy" 
                    DataSubjectField="ActivitySubject"   
                    HoursPanelTimeFormat="htt"   
                    Skin="Office2007" 
                    ValidationGroup="RadScheduler1"   
                    ShowAllDayRow="False"     
                    CustomAttributeNames="ActivityMemo,ActivityID,ActivityActionBy,UserActivityTypeRef,PriorityRef,ActivityStatusRef"   
                    StartInsertingInAdvancedForm="True" 
                    Height="548px"   
                    ShowHeader="true"   
                    AllowDelete="false"   
                    > 
                    <TimelineView UserSelectable="false" /> 
                </telerik:RadScheduler>                 
            </td> 
 
        </tr> 
    </table> 
      
    <asp:ObjectDataSource ID="odsMyDiary" runat="server" InsertMethod="InsUpdActivity" 
        OldValuesParameterFormatString="original_{0}" SelectMethod="SelectDiaries" TypeName="Safe.CRM.DAL.DAL">  
        <SelectParameters> 
            <asp:Parameter Name="ValidateUserLogonID" Type="Object" /> 
            <asp:Parameter Name="ActivityActionByIDs" Type="String" /> 
            <asp:Parameter Name="FromDate" Type="DateTime" /> 
            <asp:Parameter Name="ToDate" Type="DateTime" /> 
        </SelectParameters> 
        <InsertParameters> 
            <asp:Parameter Name="ValidateUserLogonID" Type="Object" /> 
            <asp:Parameter Name="ActivityID" Type="Object" /> 
            <asp:Parameter Name="UserActivityTypeRef" Type="Int32" /> 
            <asp:Parameter Name="ActivityCompleteBy" Type="DateTime" /> 
            <asp:Parameter Name="ActivityActionBy" Type="Object" /> 
            <asp:Parameter Name="ActivityRepeatTypeRef" Type="Int32" DefaultValue="0" /> 
            <asp:Parameter Name="ActivityStatusRef" Type="Int32" DefaultValue="0" /> 
            <asp:Parameter Name="ActivitySubject" Type="String" /> 
            <asp:Parameter Name="ActivityMemo" Type="String" /> 
            <asp:Parameter Name="EndDate" Type="DateTime" /> 
            <asp:Parameter Name="PriorityRef" Type="Int32" DefaultValue="0" /> 
            <asp:Parameter Name="ActivityParentID" Type="Object" DefaultValue="00000000-0000-0000-0000-000000000000" /> 
        </InsertParameters> 
    </asp:ObjectDataSource> 
    <asp:ObjectDataSource ID="odsPriorities" runat="server" OldValuesParameterFormatString="original_{0}" 
        SelectMethod="SelectPrioritiesML" TypeName="Safe.CRM.DAL.DAL">  
        <SelectParameters> 
            <asp:Parameter Name="ValidateUserLogonID" Type="Object" /> 
            <asp:Parameter DefaultValue="EN" Name="LangMain" Type="String" /> 
            <asp:Parameter DefaultValue="EN" Name="LangSub" Type="String" /> 
        </SelectParameters> 
    </asp:ObjectDataSource> 
 
and its code behind
    Private _DayToShow As DateTime = Now 
    Public Property DayToShow() As DateTime  
        Get  
            Return _DayToShow  
        End Get  
        Set(ByVal value As DateTime)  
            _DayToShow = value 
        End Set  
    End Property  
 
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)  
        If e.Argument = "RebindScheduler" Then  
            RadScheduler1.Rebind()  
        End If  
    End Sub  
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
        Dim menu As Telerik.Web.UI.RadPanelBar = Me.Page.Master.FindControl("MenuPanel")  
        If menu IsNot Nothing Then  
            menu.Items.FindItemByValue("Calendar").Expanded = True 
        End If  
 
        Dim consultans As List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name)  
        consultans = CType(Page.Master, ISession).SelectedConsultants  
        Dim rt As New Telerik.Web.UI.ResourceType()  
        rt.DataSource = consultans 
        rt.KeyField = "ContactID" 
        rt.TextField = "ContactName" 
        rt.Name = "Contacts" 
        rt.ForeignKeyField = "ActivityActionBy" 
        RadScheduler1.ResourceTypes.Clear()  
        RadScheduler1.ResourceTypes.Add(rt)  
        RadScheduler1.GroupBy = "Contacts" 
 
        RadScheduler1.Rebind()  
 
        If Request.QueryString("Day") IsNot Nothing Then  
            If Request.QueryString("Day").Trim <> "" Then  
                DayToShow = Request.QueryString("Day")  
                RadScheduler1.SelectedDate = DayToShow 
            End If  
        End If  
 
    End Sub  
 
    Protected Sub odsMyDiary_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles odsMyDiary.Inserting  
        e.InputParameters("ValidateUserLogonID") = myUserID().ToString  
    End Sub  
 
    Protected Sub odsMyDiary_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles odsMyDiary.Selecting  
        e.InputParameters("ValidateUserLogonID") = myUserID()  
        Dim sb As New StringBuilder  
        Dim selectContacts As List(Of Safe.CRM.DAL.BusinessObjects.Contact_Name) = CType(Page.Master, ISession).SelectedConsultants  
        For Each conact As Safe.CRM.DAL.BusinessObjects.Contact_Name In selectContacts  
            If sb.Length > 0 Then  
                sb.Append(",")  
            End If  
            sb.Append(conact.ContactID.ToString)  
        Next  
        e.InputParameters("ActivityActionByIDs") = sb.ToString  
        e.InputParameters("FromDate") = RadScheduler1.VisibleRangeStart  
        e.InputParameters("ToDate") = RadScheduler1.VisibleRangeEnd  
    End Sub  
 
    Function mySessionID() As String  
        Return CType(Page.Master, ISession).SessionData.SessionID.ToString  
    End Function  
 
    Function myUserID() As Guid  
        Return CType(Page.Master, ISession).SessionData.UserLogonID  
    End Function  
 
    Function myContactID() As Guid  
        Return CType(Page.Master, ISession).SessionData.ContactID  
    End Function  
 
    Protected Sub RadScheduler1_AppointmentCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.AppointmentCommandEventArgs)  
        Dim test As String = "" 
        Select Case e.CommandName  
            Case "Success", "Failure"  
            Case "Edit"  
            Case Else  
        End Select  
    End Sub  
 
    Protected Sub RadScheduler1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs)  
        Dim appointment As Telerik.Web.UI.Appointment = CType(e, Telerik.Web.UI.SchedulerEventArgs).Appointment  
        appointment.Attributes.Add("ValidateUserLogonID", myUserID().ToString)  
    End Sub  
 

the above sits on an ASPX page that uses the master page and loads the usercontrol Diray.ascx as the contenet area.

 

The diray renders appointemts from the supplied DB. accessed throgh a BO class and webservice. againg this works.

 

what i want to do is when a consultant is selected on the dropdown list (ajaxconultantdropdown see above) the diary is re-rendered with the new conultant, also if a date is selected on the date control (need to be able to select mutiple days, weeks etc) this caused the diray to re-render.

 

The current state of the code raises events but I can not get the scheduler to re-render, I have placed RadAhaxManagers & Porxys and AjaxRadPanels in different parts ie master page/usercontrols buts most of these caused java errors or nothing happens.

I have even removed the usercontrol from the page.controls collection and readded and still the control will not re-render.

I would like to do this all with ajax calls and without a full postback as there will be a lot of data building up on the screen.

Julian

0
Atanas Korchev
Telerik team
answered on 11 Mar 2009, 03:26 PM
Hi julian Welby Everard,

Since you seem to be updating the scheduler using the ajaxRequest method of RadAjaxManager you should add a new AjaxSetting:

<telerik:AjaxSetting AjaxControlID="RadAjaxManager1" >
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
    </UpdatedControls>
</telerik:AjaxSetting>

If this information does not help I would ask you top open a support ticket and send is a running version of your project which we can use for troubleshooting. Thanks.

Regards,
Albert
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
julian Welby Everard
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
julian Welby Everard
Top achievements
Rank 1
Share this question
or