Gloria Santin
Gloria Santin

Reputation: 2136

how to use the EventOrder attribute in fullcalendar jquery plugin

I would like to use the eventOrder attribute for the fullcalendar jquery plugin but I can't find any examples how to set the property. I added non-standard field property, description, that I would like to use. How do you set this property to the eventOrder? This is how my events currently display:

$('#calendar').fullCalendar({
    header:
    {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    titleFormat: {month: 'MMMM'},   
    defaultView: 'month',
    events: function (start, end, timezone, callback) {
        $.ajax({
            type: "POST",
            url: '@Url.Action("GetAllEvents", "Home")',
            // data: "{'userID':'" + $('#<%= hidUserID.ClientID %>').val() + "'}",  //this is what I use to pass who's calendar it is
            //completely take out 'data:' line if you don't want to pass to webmethod - Important to also change webmethod to not accept any parameters
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (doc) {
                var events = [];                     
                $(doc).each(function () { 
                    events.push({
                        title: $(this).attr('title'),  
                        start: $(this).attr('start'), 
                        end: $(this).attr('end'),
                        id: $(this).attr('id'),
                        description: $(this).attr('description')
                    });

                });
                callback(events);
                } ,                                                                   
            error: function () {
                alert("There was an error fetching events!")
            }
        });
    },
    eventRender: function (event, element) {
        element.find('.fc-title').append("<br/>" + event.description);
    },
    //this is the problem...how to set the eventOrder?
    eventOrder: ["description"]
    }

Upvotes: 2

Views: 10238

Answers (1)

Slyvain
Slyvain

Reputation: 1732

First of all you need to make sure that you're using FullCalendar v.2.4

Then, you need to remove the brackets "[ ]" around "description".

eventOrder: "description"

Check this fiddle, where I sorted by title descending: http://jsfiddle.net/slyvain/waa23ry0/

Upvotes: 7

Related Questions