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

Client-Side Force Redraw of Calendar

3 Answers 186 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
David Nowak
Top achievements
Rank 1
David Nowak asked on 11 Feb 2008, 03:08 PM
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.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 14 Feb 2008, 01:18 PM
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
0
Jeff Nafe
Top achievements
Rank 1
answered on 19 Dec 2008, 02:42 PM
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
0
Sebastian
Telerik team
answered on 19 Dec 2008, 03:04 PM
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.
Tags
Calendar
Asked by
David Nowak
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jeff Nafe
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or