Skip to content

RobertHajbok/FullCalendarMVC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is FullCalendarMVC?

FullCalendarMVC is a HTML helper for FullCalendar. Currently supported version is 3.9.0.

Where can I get it?

First, install NuGet. Then, install FullCalendar.MVC5 from the package manager console:

PM> Install-Package FullCalendar.MVC5

or FullCalendar.MVC4 if you are using MVC 4:

PM> Install-Package FullCalendar.MVC4

How to use it?

  • Reference the script and CSS files in BundleConfig.cs:
public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/scripts").Include(
        "~/Scripts/jquery-{version}.js",
        "~/Scripts/moment.js",
        "~/Scripts/fullcalendar*"));

    bundles.Add(new StyleBundle("~/bundles/styles").Include(
        "~/Content/fullcalendar.css"));
}

or in the view (Shared/_Layout.cshtml for example):

<script src="~/Scripts/jquery-3.2.1.min.js"></script>
<script src="~/Scripts/moment.min.js"></script>
<script src="~/Scripts/fullcalendar.min.js"></script>
<script src="~/Scripts/fullcalendar.helper.min.js"></script>
<link href="~/Content/fullcalendar.min.css" rel="stylesheet" />
  • Create an Action in your Controller to get the data:
public JsonResult GetDiaryEvents(DateTime start, DateTime end)
{
    return Json(LoadAllAppointmentsInDateRange(start, end).Select(x => new
    {
        id = x.ID,
        title = x.Title,
        start = x.StartDateString,
        end = x.EndDateString,
        color = x.StatusColor,
        className = x.ClassName,
        someKey = x.SomeImportantKeyID,
        allDay = false
    }).ToArray(), JsonRequestBehavior.AllowGet);
}
  • Use the HTML helper in your view, like below (notice the Events property referencing the Action above):
@Html.FullCalendar(settings =>
{
    settings.Name = "calendar";
    settings.CssClass = "css-test";
    settings.Header = new Header
    {
        Left = new ControlsBuilder().AddButton(HeaderButton.Prev).AddSeparator(HeaderSeparator.Adjacent)
                    .AddButton(HeaderButton.Next).AddSeparator(HeaderSeparator.Gap).AddButton(HeaderButton.Today),
        Center = new ControlsBuilder().AddTitle(),
        Right = new ControlsBuilder("month,agendaWeek ").AddView(AvailableView.AgendaDay)
    };
    settings.DefaultView = AvailableView.AgendaDay.ToString();
    settings.Editable = true;
    settings.AllDaySlot = false;
    settings.Selectable = true;
    settings.SlotDuration = TimeSpan.FromMinutes(15);
    settings.Events = Events.AsJsonFeed(Url.Action("GetDiaryEvents", "Home"));
})
  • The calendar should be rendered. Check the options below to see if the option you want to use is supported by the HTML helper. For details about these, check the full documentation on the FullCalendar website, or play with some settings in the FullCalendar.UI project of the source code. Also, this CodeProject article might help you understand how the jQuery plugin is linked to ASP.NET MVC.

What are the available options?

Option Comment Status
header #008000 supported
footer #008000 supported
customButtons #008000 supported
buttonIcons #008000 supported
themeSystem #008000 supported
themeButtonIcons #008000 supported
bootstrapGlyphicons #008000 supported
firstDay #008000 supported
isRTL #008000 supported
weekends #008000 supported
hiddenDays #008000 supported
fixedWeekCount #008000 supported
weekNumbers #008000 supported
weekNumbersWithinDays #008000 supported
weekNumberCalculation #008000 supported
businessHours Null is the default instead of false, empty list is used instead of true value #008000 supported
showNonCurrentDates #008000 supported
height #008000 supported
contentHeight #008000 supported
aspectRatio #008000 supported
handleWindowResize #008000 supported
windowResizeDelay #008000 supported
eventLimit #008000 supported
eventLimitClick #008000 supported
viewRender (callback) #008000 supported
viewDestroy (callback) #008000 supported
dayRender (callback) #008000 supported
windowResize (callback) #008000 supported
render (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
destroy (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ ------------------
timezone Null is the default value instead of false #008000 supported
now Function is not needed, as server-side is supported by MVC #008000 supported
----------------------- ------------------------------------------------------ ------------------
Available Views #008000 supported
Custom Views #008000 supported
Generic Views #008000 supported
View-Specific Options Might need some other options here, not very clear from documentation #008000 supported
View Object #008000 supported
defaultView #008000 supported
getView (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
changeView (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ ------------------
allDaySlot #008000 supported
allDayText #008000 supported
slotDuration #008000 supported
slotLabelFormat #008000 supported
slotLabelInterval #008000 supported
snapDuration #008000 supported
scrollTime #008000 supported
minTime #008000 supported
maxTime #008000 supported
slotEventOverlap #008000 supported
----------------------- ------------------------------------------------------ ------------------
What is List View? #008000 supported
listDayFormat Using empty string for the false value (no text displayed) #008000 supported
listDayAltFormat Using empty string for the false value (no text displayed) #008000 supported
noEventsMessage #008000 supported
----------------------- ------------------------------------------------------ ------------------
defaultDate #008000 supported
nowIndicator #008000 supported
visibleRange #008000 supported
validRange #008000 supported
dateIncrement #008000 supported
dateAlignment #008000 supported
duration #008000 supported
dayCount #008000 supported
prev (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
next (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
prevYear (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
nextYear (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
today (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
gotoDate (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
incrementDate (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
getDate (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ ------------------
locale #008000 supported
timeFormat #008000 supported
columnFormat #008000 supported
titleFormat #008000 supported
buttonText #008000 supported
monthNames #008000 supported
monthNamesShort #008000 supported
dayNames #008000 supported
dayNamesShort #008000 supported
weekNumberTitle #008000 supported
displayEventTime #008000 supported
displayEventEnd #008000 supported
eventLimitText #008000 supported
dayPopoverFormat #008000 supported
----------------------- ------------------------------------------------------ ------------------
navLinks #008000 supported
navLinkDayClick (callback) #008000 supported
navLinkWeekClick (callback) #008000 supported
dayClick (callback) #008000 supported
eventClick (callback) #008000 supported
eventMouseover (callback) #008000 supported
eventMouseout (callback) #008000 supported
----------------------- ------------------------------------------------------ ------------------
Touch Support #008000 supported
selectable #008000 supported
selectHelper #008000 supported
unselectAuto #008000 supported
unselectCancel #008000 supported
selectOverlap #008000 supported
selectConstraint #008000 supported
selectAllow #008000 supported
selectMinDistance #008000 supported
selectLongPressDelay #008000 supported
select (callback) #008000 supported
unselect (callback) #008000 supported
select (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
unselect (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ ------------------
Moment #008000 supported
Duration #008000 supported
date formatting string #008000 supported
formatRange (function) This function attached to fullCalendar object just returns a string, no need for support #0073e5 not needed
get / set options dynamically Added Name and CssClass properties to enable selectors client-side #008000 supported
on / off Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ ------------------
Event Object #008000 supported
Event Source Object #008000 supported
events (as an array) #008000 supported
events (as a json feed) Might need to add some AJAX parameters to Extended Form #008000 supported
events (as a function) #008000 supported
eventSources Configure Event Source Objects, as that covers all cases #008000 supported
allDayDefault #008000 supported
startParam #008000 supported
endParam #008000 supported
timezoneParam #008000 supported
lazyFetching #008000 supported
defaultTimedEventDuration #008000 supported
defaultAllDayEventDuration #008000 supported
forceEventDuration #008000 supported
eventDataTransform (callback) #008000 supported
loading (callback) #008000 supported
updateEvent (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
updateEvents (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
clientEvents (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
removeEvents (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
refetchEvents (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
refetchEventSources (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
addEventSource (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
removeEventSource (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
removeEventSources (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
getEventSources (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
getEventSourceById (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ ------------------
Colors #008000 supported
Background Events #008000 supported
eventColor #008000 supported
eventBackgroundColor #008000 supported
eventBorderColor #008000 supported
eventTextColor #008000 supported
nextDayThreshold #008000 supported
eventOrder All 4 versions supported as array #008000 supported
eventRenderWait #008000 supported
eventRender (callback) #008000 supported
eventAfterRender (callback) #008000 supported
eventAfterAllRender (callback) #008000 supported
eventDestroy (callback) #008000 supported
renderEvent (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
renderEvents (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
rerenderEvent (method) Added Name and CssClass properties to enable selectors client-side #008000 supported
----------------------- ------------------------------------------------------ -----------------
Requirements #008000 supported
Touch Support #008000 supported
editable #008000 supported
eventStartEditable #008000 supported
eventDurationEditable #008000 supported
dragRevertDuration #008000 supported
dragOpacity #008000 supported
dragScroll #008000 supported
eventOverlap #008000 supported
eventConstraint #008000 supported
eventAllow #008000 supported
longPressDelay #008000 supported
eventLongPressDelay #008000 supported
eventDragStart (callback) #008000 supported
eventDragStop (callback) #008000 supported
eventDrop (callback) #008000 supported
eventResizeStart (callback) #008000 supported
eventResizeStop (callback) #008000 supported
eventResize (callback) #008000 supported
----------------------- ------------------------------------------------------ -----------------
droppable #008000 supported
dropAccept #008000 supported
drop (callback) #008000 supported
eventReceive (callback) #008000 supported

Do you have an issue?

Have a bug or a feature request? Please search for existing and closed issues before submitting a new one. If your problem or idea is not addressed yet, please open a new issue. Contributions are welcome!

License, etc.

FullCalendarMVC is Copyright © 2017 Hajbok Robert under the MIT license.