Schedule agenda doubts


Hi,

I'm using the calendar control and I've some doubts

My tasks are for all day, and there are tasks duration are in weeks, so:

1. In Agenda, how can I hide tome column and add more custom columns?
2. In excel export, how can I hide custom columns?
3. The date column.... can be grouped by week number?






9 Replies

VS Velmurugan S Syncfusion Team May 1, 2018 04:39 PM UTC

Hi Manolo, 

Thanks for Contacting Syncfusion support. 

Please find the following response for your queries:  

Query #1: 1. In Agenda, how can I hide tome column and add more custom columns?  
 
You can add the custom columns and hide the time column by using our QueryCellInfo feature. Please refer to the following code example to add custom column and hide time column. 
 
<Code> 
 
<script> 
    function OnCheckInfo(args) { 
        if (args.model.currentView == "agenda") { 
            if (args.requestType == "agendacells" && args.cellType == "agendaheadercells") { 
                if (args.element.hasClass("e-timecolumn")) 
                    args.element.addClass("hide-time-column"); // Hiding time header column 
            } 
            if (args.requestType == "agendacells" && args.cellType == "agendatimecell") { 
                args.element.addClass("hide-time-column"); // Hiding time column 
            } 
            if (args.requestType == "agendacells" && args.cellType == "agendaeventcell") { 
                var customDesign = "<td class='e-agendacells loccolumn'><div class='e-textwrapper'><span>" + args.appointment.Location + "</span></div></td><td class='e-agendacells desccolumn'><div class='e-textwrapper'><span>" + args.appointment.Description + "</span></div></td>"; // to add additional field for each appointments 
                $(args.element).after(customDesign); 
            } 
            if (args.requestType == "agendacells" && args.cellType == "agendaheadercells" && $(args.element).hasClass("e-eventcolumn") && $(".e-headercells.loccolumn").length == 0) { 
                var customDesign1 = "<td class='e-headercells loccolumn'><div class='e-textwrapper'><b>Event Location</b></div></td><td class='e-headercells desccolumn'><div class='e-textwrapper'><b>Event Description</b></div></td>"//to add header for additional columns 
                args.element.after(customDesign1); 
            }             
        } 
    } 
</script> 
<style> 
    .hide-time-column { 
        display: none; 
    } 
</style> 
 
</Code> 
 
Please look into our below UG links to know more about the QueryCellInfo feature details. 

 
 
Query #2: In excel export, how can I hide custom columns? 
 
By default we will display the appointment details based on the “AppointmentsData class” fields alone in the in excel exported file. Therefore, please define the AppointmentsData class with required field to be exported. For example, we have excluded the description field in the AppointmentsData class and which is not available in the exported file. 
 
<Code> 
public class AppointmentData 
        { 
            public int Id { get; set; } 
            public string Subject { get; set; } 
            public string StartTime { get; set; } 
            public string EndTime { get; set; } 
            public bool? AllDay { get; set; } 
            public bool? Recurrence { get; set; } 
            public string RecurrenceRule { get; set; } 
            public string Location { get; set; } 
        } 
</Code> 
 
Query #3: The date column.... can be grouped by week number? 
 
Please refer to the following code example to get the week number of the date and based on that you can customize the date column as per your wish. 
 
<Code> 
 
<script> 
    function OnCreate() { 
        var obj = $("#Schedule1").data("ejSchedule"); 
        var date = new Date(obj.currentDate()); 
        var weekFirst = new Date(date.getFullYear(), date.getMonth(), date.getDate()); 
        for (var a = 0, len = obj._dateRender.length / 7 ; a < len; a++) { 
            var weekDate = weekFirst._currentWeekDates(obj._firstdayofweek); 
            var weekNo = Math.ceil((((weekDate.start - new Date(weekDate.start.getFullYear(), 0, 1)) / 86400000) + new Date(weekDate.start.getFullYear(), 0, 1).getDay() + 1) / 7);             
            var weekNumber = (weekNo > 52) ? weekNo - 52 : weekNo; // Here you can get the weekNumber 
     // Add your customized code to group the date column as per your wish 
        } 
    } 
</script> 
</Code> 

We have prepared the sample with the above code example, which can be downloaded from the following location. 


Kindly try with the above sample and let me know if you need any further assistance on this. 
Regards, 
Velmurugan 



MC Manolo Capdevila May 11, 2018 11:58 AM UTC

Hi,

Thanks for your answers!

But I have doubts about how to do the 3 point. In calendar show tasks grouped by week number

I need display some similar at this. The task are grouped by its week number



NR Nevitha Ravi Syncfusion Team May 17, 2018 07:48 AM UTC

Hi Manolo, 

Since we don’t have default support to achieve your requirement, therefore we have prepared a work-around sample for you requirement “grouping the appointments based on week number in agenda view” which can be downloaded from the below link. 

    var weeknum = 0, count = 0; 
    var nextRow = true, news, app, start, end, App, endDate; 
    function OnCheckInfo(args) { 
        if (args.model.currentView == "agenda" && args.requestType == "agendacells") { 
            if (args.requestType == "agendacells" && args.cellType == "agendatimecell") { 
                news = _getWeekno(args.appointment.StartTime); 
                if (weeknum != news) { 
                    app = this._currentViewAppointments; 
                    start = args.appointment.StartTime; 
                    end = new Date(endDate.setHours(23, 59, 59)); 
                    var predicate = ej.Predicate(this._appointmentSettings["startTime"], ej.FilterOperators.greaterThanOrEqual, start).and(this._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, end); 
                    App = new ej.DataManager(this._currentViewAppointments).executeLocal(new ej.Query().where(predicate)); 
                    nextRow = (args.appointment.StartTime.getDate() > end.getDate()) ? true : false; 
                } 
                if ((weeknum != news) || count == 0) { 
                    var customDesign = "<td class='e-agendacells datecolumn' rowspan=" + App.length + "><div class='e-textwrapper'><span> Week No:" + news + "</span></div></td>";  
                    $(args.element).before(customDesign); // to add custom column data. 
                    weeknum = news; 
                    count++; 
                } 
            } 
            if (args.requestType == "agendacells" && args.cellType == "agendaheadercells" && $(args.element).hasClass("e-timecolumn") && $(".e-headercells.datecolumn").length == 0) { 
                var customDesign1 = "<td class='e-headercells datecolumn'><div class='e-textwrapper'><b>Week</b></div></td>"; 
                args.element.before(customDesign1); // to add custom column heading 
            } 
        } 
    } 
    function OnNavigation(args) { 
        weeknum = 0, count = 0, nextRow = true; 
    } 
 
    function _getWeekno(date1) { 
        var date = new Date(date1); 
        var obj = $("#Schedule1").data("ejSchedule"); 
        var weekFirst = new Date(date.getFullYear(), date.getMonth(), date.getDate()); 
        for (var a = 0, len = obj._dateRender.length / 7 ; a < len; a++) { 
            var weekDate = weekFirst._currentWeekDates(obj._firstdayofweek); 
            endDate = weekDate.end; // to get the end date of the week 
            var weekNo = Math.ceil((((weekDate.start - new Date(weekDate.start.getFullYear(), 0, 1)) / 86400000) + new Date(weekDate.start.getFullYear(), 0, 1).getDay() + 1) / 7); 
            var weekNumber = (weekNo > 52) ? weekNo - 52 : weekNo;  
        } 
        return weekNumber; 
    } 

Please check the above sample and let us know if you need further assistance on this. 

Regards, 
Nevitha. 



MC Manolo Capdevila May 28, 2018 10:30 AM UTC

Fantastic!

It works perfectly!

Thanks a lot


NR Nevitha Ravi Syncfusion Team May 29, 2018 12:34 PM UTC

Hi Manolo,  
 
You are most welcome. We are glad that our solution fulfilled your requirement. Please let us know if you need further assistance.  
 
Regards,  
Nevitha 



MC Manolo Capdevila May 30, 2018 03:18 PM UTC

Hi again, I've other problem

When an appointmet has a long duration, this appointment is repeated in agenda week view.

I attach an example


Attachment: ScheduleWeeksAgenda_9a8c419.zip


VS Velmurugan S Syncfusion Team June 4, 2018 10:05 AM UTC

Hi Manolo, 

You can achieve your requested scenario to hide the longer duration repeated appointments, and to display only the single instance of it under the week number category, by using the below highlighted customization code within the queryCellInfo event. Please refer to the following code example. 
 
<Code> 
<style> 
    .hide-time-column { 
        display: none; 
    } 
 
    .e-timecolumn, .e-datecolumn { 
        display: none; 
    } 
 
    .appointment-hide { 
        display: none; 
    } 
</style> 
 
<script> 
    var weeknum = 0, count = 0; 
    var nextRow = true, news, app, start, end, App, endDate; 
    var appIDs = []; 
 
    function onQueryCellInfo(args) { 
        ----------------------------------------- 
  ----------------------------------------- 
 ----------------------------------------- 
         
        // The following code used to hide the repeated appointments of long duration appointment 
        if (args.model.currentView == "agenda") { 
            if (args.requestType == "agendacells" && args.cellType == "agendaeventcell") { 
                var id = args.appointment.ID; 
                if (appIDs.indexOf(id) != -1) { 
                    args.element.addClass("appointment-hide"); // Here adding the class to hide the element 
                } else { 
                    appIDs.push(args.appointment.ID);          // Here pushing the appointment ID value in an array to check its rendering and hide 
                } 
            } 
        } 
   } 
 
        function OnNavigation(args) { 
        if (args.currentView == "agenda") 
            weeknum = 0, count = 0, nextRow = true; 
        appIDs = []; 
    } 
</script> 

</Code> 

We have modified the given sample with the above code example changes, which can be downloaded from the following location. 
   
 
Kindly try with the above sample and let us know if you need any further assistance on this.   
  
Regards,   
Velmurugan   



MC Manolo Capdevila June 4, 2018 03:35 PM UTC

Hi,

It works perfect! but I'be the last question (I hope...)

¿How can I set the range in agenda date? Default range are 7 days....



VS Velmurugan S Syncfusion Team June 5, 2018 01:08 PM UTC

Hi Manolo,   
We are glad that our provided solution helps you to meet your requirement. 
You can set the range for Scheduler Agenda view dates by using the property “DaysInAgenda”. Please refer to the following code example to set the date range value (ex: 5) to the Agenda view. 
<Code> 
@(Html.EJ().Schedule("calendario") 
                                .Width("100%") 
                                .ReadOnly(true) 
                                .Locale("es-ES") 
                                .Views(views) 
                                .AgendaViewSettings(agendaViewSettings => agendaViewSettings.DaysInAgenda(5)) 
                                .CategorizeSettings(s => 
                                   s.AllowMultiple(false) 
                                   .Enable(true) 
                                )                               
</Code> 
Also, we request you to look into our below UG link to know about this DaysInAgenda property. 
Kindly try with the above suggestion and let us know if you need any further assistance on this. 
Regards,   
Velmurugan

Loader.
Up arrow icon