如何在FullCalendar Eventsources或EventsourcesUccess中为单个事件设置事件颜色

发布于 2025-01-28 12:43:13 字数 952 浏览 2 评论 0原文

我使用的是具有FullCalendar 5的Eventsources。

每个事件源都会返回不同类型的事件,然后将其颜色不同。一个源将返回三种不同类型的事件,一个包装了三个数组的对象,而不是让源解析相同的日期范围3次,每次返回一个数组。这三种事件类型中的每一种都应以不同的方式进行颜色。

EventSources条目当前看起来像这样:

      {
        // Reservation types
        url: '/reservations',
        method: 'POST',
        color: '#ffd5d5',
        textColor: 'black',
        eventClassNames: ['cal__reservations'],
      },

返回是:

{
  "type 1": [
    { "title": "type 1 title",
      "start": "2022-05-02",
      "end": "2022-05-02"}
    },
  "type 2": [
    { "title": "type 2 title",
      "start": "2022-05-04",
      "end": "2022-05-02"}
    },
  "type 3": [
    { "title": "type 3 title",
      "start": "2022-05-24",
      "end": "2022-05-24"}
    }
}
  

我想解析此返回,以便每种类型都分配了不同的颜色,但是Eventsources似乎期望来自EventsOuncesuccess的单个数组,并且该事件颜色仍在静态上定义。在整个源的Eventsources中。

Eventsources或EventSourcesuccess有没有任何方法可以为每个事件分配颜色吗?

I'm using eventSources with FullCalendar 5.

Each event source returns a different type of event which is then colored differently. One source will return three different types of events, an object with three arrays wrapped, rather than having the source parse the same date range 3 times and return one array each time. Each of the three event types should be colored differently.

The eventSources entry currently looks like this:

      {
        // Reservation types
        url: '/reservations',
        method: 'POST',
        color: '#ffd5d5',
        textColor: 'black',
        eventClassNames: ['cal__reservations'],
      },

the return is:

{
  "type 1": [
    { "title": "type 1 title",
      "start": "2022-05-02",
      "end": "2022-05-02"}
    },
  "type 2": [
    { "title": "type 2 title",
      "start": "2022-05-04",
      "end": "2022-05-02"}
    },
  "type 3": [
    { "title": "type 3 title",
      "start": "2022-05-24",
      "end": "2022-05-24"}
    }
}
  

I would like to parse this return so that each type is assigned a different color, but it seems that eventSources is expecting a single array from eventSourceSuccess and that the event color is still statically defined within eventSources for each source as a whole.

Is there any way in eventSources or in eventSourceSuccess to conditionally assign a color to each event, individually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文