FullCalendar:如何查找扩展的资源

发布于 2025-01-14 23:29:40 字数 291 浏览 2 评论 0原文

我似乎无法在 React FullCalendar 中找到一种方法来获取所有扩展的资源。您可以使用calendarAPI将资源设置为展开或不展开:

calendarApi.currentDataManager.dispatch({
          type: "SET_RESOURCE_ENTITY_EXPANDED",
          id: resource.id,
          isExpanded: expanded,
        });

但是我们如何获取资源的展开状态呢?

I can't seem to find a way in React FullCalendar to get all resources that are expanded. You can set a resource to be expanded or not expanded using calendarAPI:

calendarApi.currentDataManager.dispatch({
          type: "SET_RESOURCE_ENTITY_EXPANDED",
          id: resource.id,
          isExpanded: expanded,
        });

but how can we get the resources' expanded states?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉生梦死 2025-01-21 23:29:40

你走在正确的轨道上。如果您想展开/折叠所有资源,您可以迭代资源列表,为每个资源调度展开事件(见下文)。

//import the api
import { CalendarApi } from '@fullcalendar/common';

//add as an override to calendar api (not necessary to override, can be wrapped in a plain function)
CalendarApi.prototype.expandResources = function (expanded) {

    //fetch all resources from api
    var resources = this.getResources();
    
    //iterate through each resource, sending a dispatch event for each
    for(var resource of resources){
        this.dispatch({
            type: 'SET_RESOURCE_ENTITY_EXPANDED',
            id: resource.id,
            isExpanded: expanded,
        });
    }     
};

You are on the right track. If you'd like to expand/collapse all resources, you can iterate through the resource list, dispatching the expand event for each (see below).

//import the api
import { CalendarApi } from '@fullcalendar/common';

//add as an override to calendar api (not necessary to override, can be wrapped in a plain function)
CalendarApi.prototype.expandResources = function (expanded) {

    //fetch all resources from api
    var resources = this.getResources();
    
    //iterate through each resource, sending a dispatch event for each
    for(var resource of resources){
        this.dispatch({
            type: 'SET_RESOURCE_ENTITY_EXPANDED',
            id: resource.id,
            isExpanded: expanded,
        });
    }     
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文