Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Order of events in FullCalendar AgendaDay view

I'm using the fullCalendar jquery plugin.

I'm trying to make my events in the agendaDay view show up from left to right ordered by start time.

Essentially, I want to remove the stacking of events, so an event from 9-11 would show up next to an event from 12-4 instead of above it.

It looks like there are a few functions that are associated with the sorting of events.

function segCmp(a, b) {
    var tryCmp = (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
    if (tryCmp == 0)
        return (a.event.rowId - b.event.rowId);
    return tryCmp;
}

function segsCollide(seg1, seg2) {
    return seg1.end > seg2.start && seg1.start < seg2.end;
}

// event rendering utilities
function sliceSegs(events, visEventEnds, start, end) {
    var segs = [],
        i, len=events.length, event,
        eventStart, eventEnd,
        segStart, segEnd,
        isStart, isEnd;
    for (i=0; i<len; i++) {
        event = events[i];
        eventStart = event.start;
        eventEnd = visEventEnds[i];
        if (eventEnd > start && eventStart < end) {
            if (eventStart < start) {
                segStart = cloneDate(start);
                isStart = false;
            }else{
                segStart = eventStart;
                isStart = true;
            }
            if (eventEnd > end) {
                segEnd = cloneDate(end);
                isEnd = false;
            }else{
                segEnd = eventEnd;
                isEnd = true;
            }
            segs.push({
                event: event,
                start: segStart,
                end: segEnd,
                isStart: isStart,
                isEnd: isEnd,
                msLength: segEnd - segStart
            });
        }
    }
    return segs.sort(segCmp);
}


// event rendering calculation utilities
function stackSegs(segs) {
var levels = [],
i, len = segs.length, seg,
j, collide, k;
    for (i=0; i<len; i++) {
        seg = segs[i];
        j = 0; // the level index where seg should belong
        while (true) {
            collide = false;
            if (levels[j]) {
                for (k=0; k<levels[j].length; k++) {
                    if (segsCollide(levels[j][k], seg)) {
                        collide = true;
                        break;
                    }
                }
            }
            if (collide) {
                j++;
            }else{
                break;
            }
        }
        if (levels[j]) {
            levels[j].push(seg);
        }else{
            levels[j] = [seg];
        }
    }
    return levels;
}

Any thoughts?

like image 287
user2088036 Avatar asked May 26 '13 20:05

user2088036


2 Answers

The orientation of time slots in the calendar is from top to bottom not left to right. I don't believe it is possible to change that orientation.

like image 154
ShadeTreeDeveloper Avatar answered Sep 30 '22 04:09

ShadeTreeDeveloper


There is an option you can pass to fullCalendar()that will disable the overlapping of events in agendaDay and agendaWeek view it's slotEventOverlap: false.

like image 43
DiegoSalazar Avatar answered Sep 30 '22 05:09

DiegoSalazar