You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Fullcalendar创建资源横向、日期纵向的特定格式日历?

Can FullCalendar create a grid with horizontal resources (top) and vertical dates (left)?

Absolutely! You can build the exact calendar layout you're describing with FullCalendar—let me walk you through how to make this work perfectly for your needs.

The view you're looking for is FullCalendar's Resource Day Grid View, which is specifically designed to display resources horizontally across the top and dates vertically down the left (a key difference from the Timeline View, which focuses on time-based horizontal axes). This view lets you manage events tied to specific resources and dates, which aligns perfectly with your requirements.

Here's a step-by-step implementation breakdown:

  • Include required plugins: You'll need FullCalendar's core library plus the resourceDayGrid plugin (this adds resource-based grid functionality).
  • Configure your resources: Define Resource A/B/C in the resources array of the calendar options.
  • Set the initial view: Use initialView: 'resourceDayGrid' to load the correct layout by default.
  • Bind events to resources: When adding events, specify a resourceId to link each event to the correct resource and date.
  • Customize date formatting (optional): Adjust the left-hand date labels to match your "Apr. 26" style.

Example code snippet:

document.addEventListener('DOMContentLoaded', function() {
  const calendarEl = document.getElementById('calendar');
  const calendar = new FullCalendar.Calendar(calendarEl, {
    plugins: ['resourceDayGrid'],
    initialView: 'resourceDayGrid',
    // Define top-aligned resources
    resources: [
      { id: 'a', title: 'Resource A' },
      { id: 'b', title: 'Resource B' },
      { id: 'c', title: 'Resource C' }
    ],
    // Add events linked to specific resources and dates
    events: [
      {
        title: 'Client Check-In',
        start: '2024-04-26',
        resourceId: 'a'
      },
      {
        title: 'Team Sync',
        start: '2024-04-27',
        resourceId: 'b'
      },
      {
        title: 'Project Deadline',
        start: '2024-04-28',
        resourceId: 'c'
      }
    ],
    // Restrict calendar to your desired date range (Apr 26-29)
    validRange: {
      start: '2024-04-26',
      end: '2024-04-30' // End date is exclusive, so use the day after your last desired date
    },
    // Format left-hand dates to match "Apr. 26" style
    dayHeaderFormat: { 
      month: 'short', 
      day: 'numeric',
      omitCommas: true // Removes the comma between month and day
    }
  });

  calendar.render();
});

Key notes:

  • Unlike the Timeline View, the resourceDayGrid view prioritizes a day-based grid where each cell represents a single resource-date pair—exactly the layout you're targeting.
  • You get all of FullCalendar's built-in event management features: drag-and-drop events between resources/dates, click-to-create events, event editing, and more.
  • You can further customize styling (colors, cell sizes, etc.) using FullCalendar's CSS hooks to match your exact design needs.

This setup will give you a fully functional calendar that meets your requirements for resource/date organization and event management.


内容的提问来源于stack exchange,提问作者Patrik Alexits

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:53:14