Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit width of event in FullCalendar?

Tags:

fullcalendar

This seems incredibly easy, but I have spent half a day bashing my head against the wall trying to figure out why my fullcalendar events are showing only at 77px, when the width of the cell(month view) seems to be either 90px or higher. I have tried modifying the fc-event css rule, but it seems like javascript is writing some inline styles into the calendar, overwriting these styles.

I can't seem to find out where these styles are getting written!

Can anyone who has customized fullcalendar give some insight? It is running as a page on a wordpress blog, not sure if this has anything to do with it, as I noticed that one of the buttons is lopped off at an awkward position.

like image 376
Ying Avatar asked Aug 02 '10 16:08

Ying


People also ask

How do I set events in Fullcalendar?

Here is an example of how to specify an array of events: var calendar = new Calendar(calendarEl, { events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09T12:30:00', allDay : false // will make the time show } ] });

How do I change the height on Fullcalendar?

If "auto" is specified, the view's contents will assume a natural height and no scrollbars will be used. If "100%" is specified, the height of the calendar will match the height of its parent container element. See an example. Any other valid CSS value is accepted as well.

How do I create a dynamic event in Fullcalendar?

although it is not specified on the fullcalender site, it is necessary to assign a value to the "allday" parameter to be able to add new events dynamically. If you set this value to "false", it will not add the event to the AllDay row. If you do "true" it will add to the AllDay row. Save this answer.

How do I change the date on Fullcalendar?

The calendar's dates can change any time the user does the following: click the prev/next buttons, change the view, click a navlink. The dates can also change when the current-date is manipulated via the API, such as when gotoDate is called. datesSet is called after the new date range has been rendered.


3 Answers

you can set event width with eventAfterRender

$('#calendar').fullCalendar({
  eventAfterRender: function(event, element, view) {
                      $(element).css('width','50px');
                    }
});
like image 93
mikeonbike Avatar answered Nov 09 '22 10:11

mikeonbike


I've used !important to override the inline style and it worked fine

.fc-event{ width: 98px !important;}

like image 42
amoniz Avatar answered Nov 09 '22 09:11

amoniz


eventRender: function (event, element, view) {
    if (event.eventType == "Task") { //own property
        var one_day = 1000 * 60 * 60 * 24;
        var _Diff = Math.ceil((event.start.getTime() - view.visStart.getTime()) / (one_day));
        var dayClass = ".fc-day" + _Diff;

        if (event.days == 1) {  //own property
            jQuery(dayClass).addClass("one-day-event"); //set width to 90px (cca 2 cells)
        } else {
            jQuery(dayClass).removeClass("one-day-event");

        }
        view.setWidth(jQuery(dayClass).css("width") * event.days);
    }
},
like image 27
eXistPierre Avatar answered Nov 09 '22 09:11

eXistPierre