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

calender clientside DayRender Event not working

2 Answers 119 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ruchi
Top achievements
Rank 1
Ruchi asked on 09 Mar 2015, 10:43 AM
Hello Team,

I am using radCalender in my application. I want to highlight some special days with some counts inside it.

ClientSide dayrender event is not firing. Can anyone help me out?

Please find code below:
<telerik:RadCalendar ID="RadCalendar2" runat="server" TitleFormat="MMMM yyyy" AutoPostBack="false">
                        <ClientEvents OnDayRender="OnDayRender"></ClientEvents>
                    </telerik:RadCalendar>
function  OnDayRender(sender, args) {
                alert('hi');                 
                }

I want to achive functionality provided here(Client-Side) : http://demos.telerik.com/aspnet-ajax/calendar/examples/programming/customdaycellrendering/defaultcs.aspx?show-source=true


Thanks and Regards,
Ruchi Patel


2 Answers, 1 is accepted

Sort by
0
Ruchi
Top achievements
Rank 1
answered on 11 Mar 2015, 11:19 AM
Hello Team,

Solution : Day Render  will not fire client-side will the calendar is navigated to a view different that the current one.

I need one more help for calender itself, Please find code below:

<telerik:RadCalendar ID="Cal1" PresentationType="Preview" runat="server" DayNameFormat="Short" ShowRowHeaders="false" ShowOtherMonthsDays="false" Skin="Special" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false" EnableMonthYearFastNavigation="false">
    <CalendarDayTemplates>
        <telerik:DayTemplate ID="RedTemplate" runat="server">
            <Content>
                <div class="rcTemplate rcRed" id="radTemplateDiv" runat="server" style="background-color: #ffffff; font-weight: normal;">
                    _date<br />
                    <p style="text-align: center; font-weight: bold; font-size: 16px;">_noCount</p>
                </div>
            </Content>
        </telerik:DayTemplate>
    </CalendarDayTemplates>
    <ClientEvents OnInit="initializeCal" OnDayRender="RenderADay" OnLoad="moveToDecember" />
</telerik:RadCalendar>

<telerik:RadCodeBlock ID="rcCal" runat="server">
<script type="text/javascript">
        var jsonResultData = "";
 var senderForOnLoad = '';
        function moveToDecember(sender) {
            var todaysDate = new Date();
            if (todaysDate.getMonth() != 11)
                var triplet = [todaysDate.getFullYear() - 1, 12, 25];
            else
                var triplet = [todaysDate.getFullYear(), 12, 25];
            sender.navigateToDate(triplet);           
            senderForOnLoad = sender;
            $.get('/api/CalenderWidget?WidMapID=' + 11, function (jsonResult) {
                for (var i = 0; i < jsonResult.length; i++) {
                   // Here i need to redesign template by replacing "_date" , "_noCount" and "Color" with the result comes in jsonResult.
                }
            });
 
        }
</script>
</telerik:RadCodeBlock>

Please find comments, I need special days with colors and count comes from Database in jsonResult.

Let me know if anyone can help.


Thanks and Regards,
Ruchi Patel
0
Pavlina
Telerik team
answered on 12 Mar 2015, 11:06 AM
Hi,

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:
protected  void Cal1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
   {
       ScriptManager.RegisterStartupScript(Page, Page.GetType(), e.Day.Date.ToString(), "alert('RenderADay');", true);
   }

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar
Asked by
Ruchi
Top achievements
Rank 1
Answers by
Ruchi
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or