We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Adding the week number in the header

Thread ID:

Created:

Updated:

Platform:

Replies:

129125 Feb 28,2017 10:10 AM Mar 3,2017 01:21 AM ASP.NET MVC 5
loading
Tags: Schedule
Cornel Amarandei
Asked On February 28, 2017 10:10 AM

Hi,

It would be possible to add in the header of a Schedule in Month view the number of the week for every week in the month?

Thanks,
Cornel.

Karthigeyan Krishnamurthi [Syncfusion]
Replied On March 1, 2017 02:08 AM

  
Hi Cornel, 
 
Thank you for contacting Syncfusion support. 
 
Yes, it is possible to add week number in month view and the sample can be download from the below location. 
 
Kindly find the below code example used in the sample.    
 
<Code> 
function onCreate() { 
            var obj = $("#Schedule1").data("ejSchedule"); 
            if (obj.currentView() == "month") { 
                Date.prototype._getWeekNumber = function () { 
                    var weekNo = Math.ceil((((this - new Date(this.getFullYear(), 0, 1)) / 86400000) + new Date(this.getFullYear(), 0, 1).getDay() + 1) / 7); 
                    return (weekNo > 52) ? weekNo - 52 : weekNo; 
                }; 
                var result = $.grep($(".cusRow"), function (value) { if ($(value).hasClass("cusRow")) { return value; } }); 
                if (result.length != 0) $(".cusRow").remove(); 
                var date = new Date(obj.currentDate()); 
                var weekFirst = new Date(date.getFullYear(), date.getMonth(), 1); 
                var $tr = "<tr class='cusRow'>"; 
              Date.prototype._currentWeekDates = function (firstdayofweek) { 
                var dayDiffer = this.getDay() - firstdayofweek, 
                    start = new Date(this.getFullYear(), this.getMonth(), this.getDate() + (((dayDiffer < 0) ? dayDiffer + 7 : dayDiffer) * -1)), 
                    end = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6); 
                return { start: new Date(start), end: new Date(end) }; 
            }; 
              for (var a = 0, len = obj._dateRender.length / 7 ; a < len; a++) { 
                    var weekDate = weekFirst._currentWeekDates(obj._firstdayofweek); 
                    var weekNumber = weekDate.start._getWeekNumber(); 
                    var count = 0, total = ((weekDate.end - weekDate.start) / (1000 * 60 * 60 * 24)) + 1; 
                    for (b = 0; b < total; b++) { 
                        if (obj.monthDays.indexOf(weekDate.start.getTime() + (1000 * 60 * 60 * 24 * b)) != -1) count++; 
                    } 
                    $tr += "<td colspan='" + count + "' style='padding:5px;border-left:1px solid #c3c3c3;border-bottom:1px solid #c3c3c3;text-align: center;'>" + weekNumber + "</td>"; 
                    weekFirst = new Date(weekDate.end.getTime() + (1000 * 60 * 60 * 24)); 
                } 
                $tr += "</tr>"; 
                $($tr).insertBefore(obj.element.find(".e-headerdays").find("tr:first")); 
                obj.element.find(".cusRow").children().first().css("border-left","none"); 
                obj.refreshScroller(); 
            } 
        } 
</Code> 

Regards, 
Karthigeyan 


Cornel Amarandei
Replied On March 1, 2017 04:49 AM

Hi Karthigeyan,

Thanks for your information.

Your sample code is working well when I first open the page, but after I change the current month, the display of the Schedule is the default one again. I've tried to put the same code in a onNavigate event, but with no luck.

Do you have any suggestions?

Thanks,
Cornel.

Karthigeyan Krishnamurthi [Syncfusion]
Replied On March 2, 2017 01:06 AM

Hi Cornel, 
 
Thanks for your update. 
 
We suspect that in your sample ActionComplete event may not be used which could be the cause for the issue. We have checked the provided sample and week number is showing after navigation and for the same we have prepared the video demo which can be download from the below location. 

If issue persist kindly share your code example/runnable sample (if possible) to serve you better. 

Regards, 
Karthigeyan 


Cornel Amarandei
Replied On March 2, 2017 05:34 AM

Hi Karthigeyan,

Thanks for your information.

Adding the ActionComplete event with the same code as in the onClose(), fixed the problem.

Thanks,
Cornel.

Karthigeyan Krishnamurthi [Syncfusion]
Replied On March 3, 2017 01:21 AM

Hi Cornel, 
 
We are happy that our solution has fulfilled your requirement. 
 
Please let us know if you need further assistance. 
 
Regards, 
Karthigeyan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;