给定一天的所有事件的总特定属性 - 全球
每天的每天都有一个扩展道具
需求:我知道 。日常的细胞内容挂钩看起来非常有前途,但是当事件不全部都在内存中并且相当不同步时,由于日托在返回数据之前呈现,因此无法正常工作。当返回数据时,我找不到一个很好的方法来解决此问题。
这是一些示例代码,可以在事件中进行内存,对异步事件(Vuejs,但对于香草来说应该相似),可以执行某些逻辑:
injectCellContent: function(arg) { // this is the day cell content hook
let CalendarAPI = this.$refs.calendar.getApi();
let events = CalendarAPI.getEvents();
let thisDate = moment(arg.date);
let thisDaysEvents = events.filter(event => moment(event.start).isSame(thisDate, 'day'));
console.log(thisDaysEvents); // aggregate the values for events on this day
}
大声思考,几乎感觉就像是直观的。将天事件作为日常细胞渲染钩的论点的一部分,但我知道它们彼此脱钩。
问题:如何在给定的日期/日期中从多个事件中汇总值?
Requirement: Total an extended prop on 0..n events on every day cell
I understand there are day cell render hooks like day cell content hook among other hooks that we can utilize to accomplish this. The day cell content hook looks very promising, but fails to work when the events are not all in memory and are rather loaded asynchronously because the daycells render before the data is returned. I could not find a good way to work around this short of perhaps rerendering the entire calendar when the data is returned.
Here is some example code that does some of the logic in the case the events ARE IN MEMORY, DOES NOT WORK FOR ASYNCHRONOUS EVENTS (VueJS, but should be similar for Vanilla):
injectCellContent: function(arg) { // this is the day cell content hook
let CalendarAPI = this.$refs.calendar.getApi();
let events = CalendarAPI.getEvents();
let thisDate = moment(arg.date);
let thisDaysEvents = events.filter(event => moment(event.start).isSame(thisDate, 'day'));
console.log(thisDaysEvents); // aggregate the values for events on this day
}
Thinking out loud, it almost feels like it would be intuitive to have the days events as part of the argument for the day cell render hook, but I understand they are decoupled from each other.
Question: How can I aggregate values from multiple events for a given day/date?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管有些混乱,但以下是我最终实现这一目标的方式。请注意,使用日常单元格式钩子(我相信DaycellContent),我首先通过注射插入式函数向DOM添加了一个容器。通过回调成功地进行了恢复的源事件,召集了Addemployeecounts。如果要调整或移动一天,则需要使用本机事件的条件来恢复计数,并通过FullCalendar选项再次使用回调。
Although a little messy, the following was how I ended up achieving this. Note that using the day cell render hooks (dayCellContent, I believe), I first added a container to the DOM via injectCellContent function. addEmployeeCounts was called upon the source events refetching successfully via callback. The condition for native events was needed to rerender the counts in the event that a single day was resized or moved, again using callbacks via fullcalendar options.