javascript - agendaWeek 和 agendaDay 上的 FullCalendar 冲突

标签 javascript jquery fullcalendar fullcalendar-3

我配置了一个在同一页面上有 AgendaDay 和 AgendaWeek 的日历。 任何东西在两个 View 上都可以正常工作,但需要对资源进行一些小的更改。

对于 Day,我加载了教师列表并将它们显示为列,但如果我想在周 View 中工作,我应该删除资源代码。在此更改之后,议程周也将正常工作。

正如您通过这种方法看到的那样,只有其中一个会同时工作。

我使用 FullCalendar v3 资源回调函数

resources: function(callback){
  jQuery('input[name="start"]').val($('#calendar').fullCalendar('getView').start.format());
  jQuery('input[name="end"]').val($('#calendar').fullCalendar('getView').end.format());
  $.ajax({
    url: resourcesCallback,
    type: 'GET',
    dataType: "json",
    data: jQuery('.calendar_filter_form').serialize(),
    error: function() {
      // alert('Oops! Try again.');
    },
    success: function(response){
      callback(response);
    }
  });
}

那么我如何才能将它设置为仅在 AgendaDay 时加载资源并在 AgendaWeek 时忽略它?

这是我尝试处理更多动态的演示。 https://codepen.io/nasser-ali-karimi/pen/QWLvypO?editors=0010

我的输出: enter image description here enter image description here

Update the question

正如我所检查的,资源回调没有问题。实际上,问题出在日历配置上。 1- groupByResource: true 2- groupByDateAndResource: true

当我将两者都设为 true 时,议程日显示以正确格式分组的数据,而不是在 AgendaWeek 上。 码笔演示https://codepen.io/nasser-ali-karimi/pen/ExYXWer?editors=0010

您可以通过此切换将 groupByDateAndResource 更改为 false,分组将更改并变为基于讲师和天数(在演示中看起来更好。)

Main Issue: I need to change the configuration for Agenda Day and Agenda Week specifically, In my case, I need to use groupByDateAndResource: True and groupByResource: true for Agenda Day but these two items should be false for Agenda Week on the same page.

最佳答案

正如我所检查的,资源回调没有问题。实际上,问题出在日历配置上。

1- groupByResource: true 

2- groupByDateAndResource: true

所以我需要为 Agenda Day 使用 groupByDateAndResource: TruegroupByResource: true 但是这两项对于 Agenda Week 应该是 false同一页。

所以我用 View 选项来做到这一点 https://codepen.io/nasser-ali-karimi/pen/mdbwmdO?editors=0010

$("#calendar").fullCalendar({
    defaultView: "agendaDay",
    views: {
      week: {
        groupByResource: false,
        groupByDateAndResource: false,
      },
      day: {
        groupByResource: true,
        groupByDateAndResource: true,
      },
    },
    ...
  });

关于javascript - agendaWeek 和 agendaDay 上的 FullCalendar 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57670120/

相关文章:

javascript - 切换不适用于复选框

javascript - 网络包 : Import CSS

javascript - useEffect 钩子(Hook)在方向改变时不触发

javascript - 在 RxJS 中拆分可观察到的错误

javascript - 如何重启 AudioBufferSourceNode?

javascript - 带有 CSS 动画问题的 jQuery 可点击下拉列表

javascript - 正则表达式验证问题

javascript - 如何使联系表格提交对电子邮件的回复?

angularjs - 获取全日历事件的 html 元素

jquery - 全日历事件标题。我不希望每一行都重复