Search results

Row Auto Height in ASP.NET MVC Schedule control

By default, the height of the Scheduler rows in Timeline views are static and therefore, when the same time range holds multiple overlapping appointments, a +n more text indicator will be displayed. With this feature enabled, you can now view all the overlapping appointments present in those specific time range by auto-adjusting the row height based on the presence of the appointments count, instead of displaying the +n more text indicators.

To enable auto row height adjustments on Scheduler Timeline views and Month view, set true to the rowAutoHeight property whose default value is false.

This auto row height adjustment is applicable only on all the Timeline views as well as on the calendar Month view.

Now, let’s see how it works on those applicable views with examples.

Calendar month view

By default, the rows of the calendar Month view can hold only the limited appointments count based on its row height, and the rest of the overlapping appointments are indicated with a +n more text indicator. The following example shows how the month view row auto-adjusts based on the number of appointments count, when this RowAutoHeight feature is enabled.

razor
data.cs
@using Syncfusion.EJ2.Schedule

@(Html.EJS().Schedule("schedule")
    .Width("100%")
    .Height("550px")
    .Views(view => {
        view.Option(View.Month).Add();
    })
    .EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
    .RowAutoHeight(true)
    .SelectedDate(new DateTime(2019, 1, 10))
    .Render()
)
public ActionResult Index()
{
    ViewBag.datasource = GetScheduleData();
    return View();
}

public List<AppointmentData> GetScheduleData()
{
    List<AppointmentData> appData = new List<AppointmentData>();
    appData.Add(new AppointmentData
    { Id = 1, Subject = "Explosion of Betelgeuse Star", Location = "Dallas", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 2, Subject = "Thule Air Crash Report", Location = "Texas", StartTime = new DateTime(2019, 1, 10, 12, 0, 0), EndTime = new DateTime(2019, 1, 10, 14, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 3, Subject = "Blue Moon Eclipse", Location = "Australia", StartTime = new DateTime(2019, 1, 10, 10, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 4, Subject = "Meteor Showers in 2019", Location = "Canada", StartTime = new DateTime(2019, 1, 10, 13, 0, 0), EndTime = new DateTime(2019, 1, 10, 14, 30, 0) });
    appData.Add(new AppointmentData
    { Id = 5, Subject = "Milky Way as Melting pot", Location = "Mexico", StartTime = new DateTime(2019, 1, 10, 12, 0, 0), EndTime = new DateTime(2019, 1, 10, 14, 0, 0) });
    return appData;
}

public class AppointmentData
{
    public int Id { get; set; }
    public string Subject { get; set; }
    public string Location { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
}

Timeline views

When the feature RowAutoHeight is enabled in Timeline views, the row height gets auto-adjusted based on the number of overlapping events occupied on the same time range, which is demonstrated in the following example.

razor
data.cs
@using Syncfusion.EJ2.Schedule

@(Html.EJS().Schedule("schedule")
    .Width("100%")
    .Height("650px")
    .RowAutoHeight(true)
    .SelectedDate(new DateTime(2019, 1, 10))
    .CurrentView(View.TimelineWeek)
    .Views(ViewBag.view)
    .EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
    .Render()
)
public ActionResult Index()
{
    ViewBag.datasource = GetScheduleData();
    List<ScheduleView> viewOption = new List<ScheduleView>()
    {
        new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.TimelineDay },
        new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.TimelineWeek },
        new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.TimelineWorkWeek },
        new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.TimelineMonth },
        new ScheduleView { Option = Syncfusion.EJ2.Schedule.View.Agenda }
    };
    ViewBag.view = viewOption;
    return View();
}

public List<AppointmentData> GetScheduleData()
{
    List<AppointmentData> appData = new List<AppointmentData>();
    appData.Add(new AppointmentData
    { Id = 1, Subject = "Explosion of Betelgeuse Star", Location = "Dallas", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 2, Subject = "Thule Air Crash Report", Location = "Texas", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 3, Subject = "Blue Moon Eclipse", Location = "Australia", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 4, Subject = "Meteor Showers in 2019", Location = "Canada", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 5, Subject = "Milky Way as Melting pot", Location = "Mexico", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 6, Subject = "Mysteries of Bermuda Triangle", Location = "Bermuda", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 7, Subject = "Glaciers and Snowflakes", Location = "Himalayas", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 8, Subject = "Life on Mars", Location = "Space Centre USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 9, Subject = "Alien Civilization", Location = "Space Centre USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 10, Subject = "Wildlife Galleries", Location = "Africa", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 11, Subject = "Best Photography 2018", Location = "London", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 12, Subject = "Smarter Puppies", Location = "Sweden", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 13, Subject = "Myths of Andromeda Galaxy", Location = "Space Centre USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 14, Subject = "Aliens vs Humans", Location = "Research Centre of USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 15, Subject = "Facts of Humming Birds", Location = "California", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 16, Subject = "Sky Gazers", Location = "Alaska", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 17, Subject = "The Cycle of Seasons", Location = "Research Centre of USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 18, Subject = "Space Galaxies and Planets", Location = "Space Centre USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 19, Subject = "Lifecycle of Bumblebee", Location = "San Fransisco", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    appData.Add(new AppointmentData
    { Id = 20, Subject = "Alien Civilization", Location = "Space Centre USA", StartTime = new DateTime(2019, 1, 10, 9, 30, 0), EndTime = new DateTime(2019, 1, 10, 11, 0, 0) });
    return appData;
}

public class AppointmentData
{
    public int Id { get; set; }
    public string Subject { get; set; }
    public string Location { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
}

Timeline views with multiple resources

The following example shows how the auto row adjustment feature works on timeline views with multiple resources.

razor
data.cs
@using Syncfusion.EJ2.Schedule

@(Html.EJS().Schedule("schedule")
    .Width("100%")
    .Height("650px")
    .RowAutoHeight(true)
    .SelectedDate(new DateTime(2018, 2, 11))
    .CurrentView(View.TimelineWeek)
    .Views(view => {
        view.Option(View.TimelineDay).Add();
        view.Option(View.TimelineWeek).Add();
        view.Option(View.TimelineWorkWeek).Add();
        view.Option(View.TimelineMonth).Add();
        view.Option(View.Agenda).Add();
    })
    .Group(group => group.EnableCompactView(false).Resources(ViewBag.ResourceNames))
    .Resources(res => {
        res.DataSource(ViewBag.RoomDatas).Field("RoomId").Title("Room Type").Name("MeetingRoom").TextField("name").IdField("id").ColorField("color").AllowMultiple(true).Add();
    })
    .EventSettings(e => e.Fields(f =>
        f.Subject(sub => sub.Name("Subject").Title("Summary"))
        .Location(loc => loc.Name("Location").Title("Location"))
        .Description(des => des.Name("Description").Title("Comments"))
        .StartTime(st => st.Name("StartTime").Title("From"))
        .EndTime(et => et.Name("EndTime").Title("To"))
    )
    .DataSource(ViewBag.datasource))
    .Render()
)
public ActionResult Index()
{
    ViewBag.datasource = GetScheduleData();
    List<RoomData> rooms = new List<RoomData>();
    rooms.Add(new RoomData { name = "Room A", id = 1, color = "#98AFC7" });
    rooms.Add(new RoomData { name = "Room B", id = 2, color = "#99c68e" });
    rooms.Add(new RoomData { name = "Room C", id = 3, color = "#C2B280" });
    rooms.Add(new RoomData { name = "Room D", id = 4, color = "#3090C7" });
    rooms.Add(new RoomData { name = "Room E", id = 5, color = "#95b9" });
    rooms.Add(new RoomData { name = "Room F", id = 6, color = "#95b9c7" });
    rooms.Add(new RoomData { name = "Room G", id = 7, color = "#deb887" });
    rooms.Add(new RoomData { name = "Room H", id = 8, color = "#3090C7" });
    rooms.Add(new RoomData { name = "Room I", id = 9, color = "#98AFC7" });
    rooms.Add(new RoomData { name = "Room J", id = 10, color = "#778899" });
    ViewBag.RoomDatas = rooms;
    string[] resources = new string[] { "MeetingRoom" };
    ViewBag.ResourceNames = resources;
    return View();
}

public class RoomData
{
    public int id { set; get; }
    public string name { set; get; }
    public string color { set; get; }
}

public List<AppointmentData> GetScheduleData()
{
    List<AppointmentData> appData = new List<AppointmentData>();
    appData.Add(new AppointmentData
    { Id = 1, Subject = "Explosion of Betelgeuse Star", StartTime = new DateTime(2018, 2, 11, 9, 30, 0), EndTime = new DateTime(2018, 2, 11, 11, 0, 0), RoomId = 1 });
    appData.Add(new AppointmentData
    { Id = 2, Subject = "Thule Air Crash Report", StartTime = new DateTime(2018, 2, 11, 9, 30, 0), EndTime = new DateTime(2018, 2, 11, 11, 0, 0), RoomId = 1 });
    appData.Add(new AppointmentData
    { Id = 3, Subject = "Blue Moon Eclipse", StartTime = new DateTime(2018, 2, 11, 9, 30, 0), EndTime = new DateTime(2018, 2, 11, 11, 0, 0), RoomId = 1 });
    appData.Add(new AppointmentData
    { Id = 4, Subject = "Meteor Showers in 2018", StartTime = new DateTime(2018, 2, 11, 9, 30, 0), EndTime = new DateTime(2018, 2, 11, 11, 0, 0), RoomId = 1 });
    appData.Add(new AppointmentData
    { Id = 5, Subject = "Milky Way as Melting pot", StartTime = new DateTime(2018, 2, 11, 9, 0, 0), EndTime = new DateTime(2018, 2, 11, 11, 30, 0), RoomId = 2 });
    return appData;
}

public class AppointmentData
{
    public int Id { get; set; }
    public string Subject { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
    public int RoomId { get; set; }
}