开发者

How can I display additional information about an event on a jQuery FullCalendar? is there a way to schedule recurring events on the calendar?

开发者 https://www.devze.com 2023-03-14 05:32 出处:网络
I\'m writing an asp.net mvc room reservation app where i\'m trying to integrate the fullcalendar. so when someone reserves a room for an event, they choose a time for the event, give it a title, and t

I'm writing an asp.net mvc room reservation app where i'm trying to integrate the fullcalendar. so when someone reserves a room for an event, they choose a time for the event, give it a title, and the system assigns a reservation ID for the event. Then on the dayslot of the calendar we see the time reserved for the event and the title of this event. So I'd like to display a reservation ID next to the time instead of the title of the event, like "8:00 -10:00 am Reservation ID#123". Is it possible? Do I need to edit the core file, ful开发者_运维问答lcalendar.js?

Also, is there a way to schedule recurring events on the calendar?

Thank you very much!


Build a property that represents the title of the event as you want it.

Your controller action

public JsonResult GetEvents(double start, double end)
{
    //Bunch of work to deal with date format and retrieve data

    var urlHelper = new UrlHelper(ControllerContext.RequestContext);

    var result = from e in eventList
             select
                 new
                     {
                         id = e.EventId,
                         title = e.StartDate.ToString("s") + " - " +
                                                     e.EndDate.ToString("s") + 
                                                     " Reservation ID#" +
                                                     e.ReservationNumber,
                         start = e.StartDate.ToString("s"),
                         end = e.EndDate.ToString("s"),
                         url = urlHelper.Action("Details", "Event", 
                                                     new {id = e.EventId}),
                         color = e.IsActive ? "#2E9AFE" : "#FA5858"
                     };

    var rows = result.ToArray();

    return Json(rows, JsonRequestBehavior.AllowGet);
}

As far as recurring events go, you have to build this up yourself. I basically created a standard CRUD add event action that also asked for a recurs until date.

When you get your list of events back you can iterate over the collection to find those events with a recurrence. When you find one you have to go through the process of determining the "virtual" recurring events to add. I basically determined a list of dates between now and the end of the recurrence that should have a recurring event.

Once you have those list of dates for the recurrence, create a new event for each of them with the id of the original event and all the other particulars. That way, when you click on the calendar event, they are represent the same event. Take this new list of events, tack it on to your original list of events, and you're set. Your calendar will display the recurring events and be none the wiser.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消