Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在c#asp.net中的fullcalendar.js插件上加载生日_Javascript_C#_Jquery_Asp.net Web Api - Fatal编程技术网

Javascript 如何在c#asp.net中的fullcalendar.js插件上加载生日

Javascript 如何在c#asp.net中的fullcalendar.js插件上加载生日,javascript,c#,jquery,asp.net-web-api,Javascript,C#,Jquery,Asp.net Web Api,我正在尝试将生日加载到fullcalendar.js。据我所知,生日应该是每年一次,比如说,我的数据库生日栏中有这样的生日(注意:我使用了短日期格式) 2016年9月18日 2016年10月20日 2016年10月28日 2016年10月27日 2016年11月2日 2016年11月3日 1992年5月4日 2017年1月13日 将这些日期拉到我的日历插件中,我只会看到2017年1月13日的生日显示,其他日期不会显示,除非我去到它们的特定年份,例如2016年10月28日,因为它是2016年,

我正在尝试将生日加载到fullcalendar.js。据我所知,生日应该是每年一次,比如说,我的数据库生日栏中有这样的生日(注意:我使用了短日期格式)

  • 2016年9月18日
  • 2016年10月20日
  • 2016年10月28日
  • 2016年10月27日
  • 2016年11月2日
  • 2016年11月3日
  • 1992年5月4日
  • 2017年1月13日
将这些日期拉到我的日历插件中,我只会看到2017年1月13日的生日显示,其他日期不会显示,除非我去到它们的特定年份,例如2016年10月28日,因为它是2016年,10月28日,当然这些日期必须每年显示。我应该能够在今年看到这些日期,但在他们尊敬的时候我的c代码如下所示

public object GetCalendarData()
{
    var currentDate = DateTime.Now.Date;
    var birthDays = from e in _userProfileRepository.Table.ToList()
        where e.Birthday != null
        group e by e.Birthday
            into g
        select new
        {
            Date = g.Key.Value,
            Count = g.Count(),
            UserProfileIds = g.Select(x => x.Id).ToList(),
            Category = 1
        };

    var subscriptions = from e in _estateRepository.Table.ToList()
        where e.SubscriptionExpiryDate <= currentDate
        group e by e.SubscriptionExpiryDate.Date 
            into g
        select new
        {
            Date = g.Key,
            Count = g.Count(),
            UserProfileIds = g.Select(x => x.UserProfileId).ToList(),
            Category = 2
        };

    return birthDays.Union(subscriptions).ToList().Select(x=>new
    {
        x.Date,
        x.Count,
        x.Category,
        x.UserProfileIds
    });
}

当用户在日历中以年为单位来回导航时,如何在确切的月份和日期显示生日?您必须为要显示生日的每一年提供一个单独的事件对象。FullCalendar不知道您的数据与生日相关,它只将其视为特定日期的事件。它仅显示n那些特定的年份,因为您在事件数据中告诉它特定的年份(根据需要)。您可以根据日历的使用模式,决定您希望用户合理查看日历的前后年份,并为该范围内的年份生成足够的生日事件数据

FullCalendar对重复事件的支持有限(您提供了一个事件对象,并告诉它以给定的间隔重复事件),但不幸的是,您目前只能生成每日或每周重复事件,因此它对年度事件(如生日)不起作用

另外,如果您的数据库存储生日(与出生日期相反)然后它就不需要存储年份,因为生日与特定年份没有关联。但是,如果您已经获得了此人的出生日期,那么最好存储该日期,然后您可以计算他们未来的生日,以及他们在任何给定日期的年龄,如果您将来需要的话

我唯一能想到的解决反复出现的生日问题的方法可能是:

1) 在页面中插入一个javascript变量,其中包含以天和月(不含年)表示的所有生日的列表


2) 处理FullCalendar-的ViewRender事件。每次视图或日期范围更改时,请对照生日列表检查显示的日期。如果任何生日属于当前显示的日/月范围(不考虑年份),请使用renderEvent方法--将新事件插入到日历中,以获得正确的日/月/年组合。(你可能想检查那一年是否还没有该生日的活动,例如,如果用户在日历渲染后已经访问了该视图。为此,你可以在JS生日对象中添加一个字段,该字段可以保存已渲染事件的年份数组。)

哇,我喜欢这个兄弟。谢谢我试试看this@IdowuMatthewDamilola太好了。如果您发现答案对您有帮助,请记住向上投票和/或标记为已接受的答案-谢谢:-)
function FullCalendar($window, $filter) {
return {
    restrict: "EAC",
    link: link
};
function link(scope, element, attrs) {
    /*  Initialize the calendar  */
    scope.$watch('waiting', function (newValue) {
        if (!newValue) {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();
            var form = '';
            var today = new Date($.now());
            var defaultEvents = scope.dashboardData.calendarData.map(function (item) {
                return {
                        title: item.count+(item.category == 1 ? " birthday(s)" : "Expired Subscriptions")),
                        start: item.date,
                        category: item.category,
                        className: item.category == 1 ? 'bg-primary' : 'bg-warning',
                        userProfileIds: item.userProfileIds
                    };

                };
            });
            $(element).fullCalendar({
                defaultDate: $.now(),
                slotDuration: '00:15:00',
                minTime: '08:00:00',
                maxTime: '19:00:00',
                defaultView: 'month',
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                events: defaultEvents,
                editable: true,
                //  droppable: true, // this allows things to be dropped onto the calendar !!!
                selectable: true,
                eventClick: function (calEvent, jsEvent, view) { 
                    switch (calEvent.category) {
                            case 1:
                                scope.openBirthdayListModal(calEvent.userProfileIds);
                                break;
                            case 2:
                                scope.openSubscriptionModal(calEvent.userProfileIds);
                                break;
                            default:
                        }
                }
            });
        }
    });
}
}

FullCalendar.$inject = ["$window", "$filter"];

angular.module("app").directive("fullCalendar", FullCalendar); 
var dashboardData;