Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add extra fields to fullcalendar

Tags:

fullcalendar

I need to create more fields for my calendar ( fullcalendar hooked up to mysql with php ). And I have been reading up on eventRender but I'm not entirely sure of the syntax and where I should put it.

Currently I have the following;

$calendar.fullCalendar({
  timeslotsPerHour : 4,
  defaultView:'agendaWeek',
  allowCalEventOverlap : true,
  overlapEventsSeparate: true,
  firstDayOfWeek : 1,
  businessHours :{start: 8, end: 18, limitDisplay: true },
  daysToShow : 7,
        theme: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },

        editable: true,
        events: "json-events.php",
  eventRender : function(calEvent, $event) {
       calEvent.distributor  //this is my new field

  },

But I its not working and I can't find any working examples to compare it with. Thanks


Thanks for the feedback I have been able to add my custom fields using the eventRender. So now not just body and description are being passed.

My main issue now is passing the date values to the database as these are not being saved. Does anyone know of any examples where this is being used. I would really really appreciated it.

like image 467
Arial Avatar asked Aug 27 '10 15:08

Arial


People also ask

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 select multiple dates in FullCalendar?

Detect when the user clicks on dates or times. Give the user the ability to select multiple dates or time slots with their mouse or touch device. Allows a user to highlight multiple days or timeslots by clicking and dragging.


3 Answers

In version 4 of fullcalendar, to get non-standard field is changed a little bit. Now it accepts just one parameter as Event Object:

 events: [
{
  title: 'My Event',
  start: '2010-01-01',
  description: 'This is a cool event'
}
// more events here
],
eventRender: function(info) {
  console.log(info.event.extendedProps.description);
}

Note: You can access an additional field in this way: info.event.extendedProps.description

Check documentation

like image 143
Mërgim Uka Avatar answered Oct 24 '22 11:10

Mërgim Uka


you can include your own non-standard fields in each Event Object. FullCalendar will not modify or delete these fields.,this example help you eventRender

and see Event Object

like image 30
Akyegane Avatar answered Oct 24 '22 10:10

Akyegane


Here is how I used eventRender to add some categories to each event. Then I can filter events based on category name

eventRender: function(event, element) {
        element.attr("categories",event.categoryname)
    }

Simply awesome calendar

like image 7
Mat Kay Avatar answered Oct 24 '22 09:10

Mat Kay