Client-Side Force Redraw of Calendar

4 posts, 0 answers
  1. David Nowak
    David Nowak avatar
    10 posts
    Member since:
    Jun 2005

    Posted 11 Feb 2008 Link to this post

    I have a main form containing a RadCalendar.  When the user selects a date on the calendar, a RadWindow opens a child window where some data is loaded for the specific date selected.  When the user closes the RadWindow, I want the calendar to be refreshed.  Currently, in my main form, I have the following logic, which works perfectly when the form first loads.  I want the calendar to be refreshed when the child window closes.

    protected void RadCalendar1_DayRender1(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
    {
        DateTime currentCalendarDate = e.Day.Date;

        // some logic here to check a database table for the currentCalendarDate to
        // see if some data has been imported for that date.

        if (dataIsImport == true)
        {
            drTradeHistoryHeader = dtTradeHistoryHeader[0];
            
    TableCell currentCell = e.Cell;
            currentCell.Style[
    "background-color"] = "lemonchiffon";
            currentCell.Text =
    "Imported" + "<br/>" + currentCalendarDate.Day.ToString();
        }
    }

    Thank You,

    David Nowak.

  2. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 14 Feb 2008 Link to this post

    Hello David,

    The server-side DayRender event will be fired only on postback event or initial load. By default the calendar works in client mode (AutoPostBack="false"), so DayRender will not be fired on navigation, selection etc. You would have to either enable postback for the calendar control, or simply invoke refresh of the page via javascript, hooked up to the OnClientClose of the RadWindow:

     <script type="text/javascript">
        function RefreshPage()
        {
         window.location= window.location.pathname;
        }
        </script>

    Hope this helps.

    Sincerely yours,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Jeff Nafe
    Jeff Nafe avatar
    46 posts
    Member since:
    Sep 2007

    Posted 19 Dec 2008 Link to this post

    Is there a better way to do this? I have a similar situation in which I need to redraw the Calendar after performing another action on the page. I somehow need the code in either the client or server side DayRender events to run so that I can perform some functionality (disabling all "non-Monday" in my case). Is there any calender.Refresh/Reload/Rerender type function on either the server or client?

    I am using Q3 2008 SP1
  4. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 19 Dec 2008 Link to this post

    Hi Jeff,

    Initially RadCalendar is rendered on the server and that is why OnDayRender client-side event is not raised. Another possible solution is to register your script using server-side DayRender event. Here is an example:
      
    void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)  
    {  
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), e.Day.Date.ToString(), "alert('RadCalendar1_DayRender');"true);  

    Kind regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top