Search results

Calendar Views

The Calendar has the following pre-defined views that provide a flexible way to navigate back and forth when selecting dates.

View Description
month (default) Displays the days in a month.
year Displays the months in a year.
decade Displays the years in a decade.

When view is defined to the start property of the Calendar, it allows you to set the initial view on rendering.

The following example demonstrates how to set the year as the start view of the Calendar.

razor
views.cs
@Html.EJS().Calendar("element").Value(@ViewBag.value).Start(Syncfusion.EJ2.Calendar.CalendarView.Year).Render()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace EJ2CoreSampleBrowser.Controllers
{
    public partial class CalendarController : Controller
    {
        // GET: /<controller>/
        public IActionResult sample()
        {   
            ViewBag.value = new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Date );
            return View();
        }
    }
}

View restriction

By defining the start and depth property with the different view, drill- down and drill-up views navigation can be limited to the user. Calendar views will be drill-down up to the view which is set in depth property and drill-up up to the view which is set in start property.

The following example displays the Calendar in decade view, and allows you to select a date in month view.

Depth view should always be smaller than the start view. If the depth and start views are the same, then the Calendar view remains unchanged.

razor
restriction.cs
@Html.EJS().Calendar("element").Value(@ViewBag.value).Depth(Syncfusion.EJ2.Calendar.CalendarView.Year).Start(Syncfusion.EJ2.Calendar.CalendarView.Decade).Render()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace EJ2CoreSampleBrowser.Controllers
{
    public partial class CalendarController : Controller
    {
        // GET: /<controller>/
        public IActionResult sample()
        {   
            ViewBag.value = new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Date );
            return View();
        }
    }
}