search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to remove "old" header area

Asked by Chris Laurie
1 month ago.

I keep my holidays in an array and code the header area as per the documentation for coloring holidays. The user can change the list of holidays. When I then reload the holidays with the new days the old holiday header areas remain. I have tried various approaches but none seems to work. My last attempt:

function BeforeTimeHeaderRender (args) {
    if (args.header.level === 1) {
        var dayOfWeek = args.header.start.getDayOfWeek();
        var item = globalHolidays.find(function(range) {
          var start = new DayPilot.Date(range.start);
          var end = new DayPilot.Date(range.end).addDays(1);
          return DayPilot.Util.overlaps(start, end, args.header.start, args.header.end);
        });

        if (item) {
          var start = new DayPilot.Date(item.start);
          var end = new DayPilot.Date(item.end).addDays(1);
          args.header.areas = [
            {
              ... set area here
            }
          ];
        } else if(args.header.areas?.length > 0){
            args.header.areas = undefined;
            //args.header.areas = [];
        //} else if(args.header.areas !== undefined){
            //args.header.areas = undefined;
            //args.header.areas = [];
        }
    } 
}
Answer posted by Dan Letecky [DayPilot]
1 month ago.

After changing the holiday definitions (globalHolidays), you need to call the update() method to refresh the Scheduler. This will generate a new time header (using onBeforeTimeHeaderRender).

Also, make sure that your onBeforeTimeHeaderRender handler references the correct globalHolidays (be careful with closures).

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.