如何动态更改视图日期(按日期时间过滤事件)

时间:2015-09-28 10:10:57

标签: angularjs kendo-ui kendo-scheduler kendo-datepicker

我希望按日期过滤事件,但日期通过正常输入类型="文本"不是kendo默认的datepicker。并且在kendo schduler header中显示传递日期但是不能改变查看日期。这是我的代码.........

 parameterMap: function (options, operation) {
                var popupheight = $(window).height() - 180 + 'px';
                $scope.popupWraperForTryout = popupheight;
                var scheduler = $("#scheduler").data("kendoScheduler");
                if (searchCount != 0) {
                    if (operation === "read") {
                        return {
                            filterByPersonalEvent: $scope._filterParamObj.filterBypersonal,
                            filterBySignUpRequired: $scope._filterParamObj.filterBySingupRequired,
                            filterByPaidOrFree: $scope._filterParamObj.filterByPaid,
                            filterByEventStatus: $scope._filterParamObj.eventStatusId,
                            filterByEventType: $scope._filterParamObj.eventTypeId,
                            selectedTeam: $scope._filterParamObj.seasonTeamId,
                            filterByStartDate: scheduler.view().startDate(),
                            filterByEndDate: scheduler.view().endDate(),
                            OrgId: _orgId,
                            UserTimezone: global.userTimezoneOffset
                        }
                    }
                }
            },

这是我的过滤器参数

{{1}}

我太累了。这段代码在视图日期没有变化。请帮帮我

1 个答案:

答案 0 :(得分:1)

这里有几个问题 - 日视图只显示一天;你不能设置startDate和endDate - 只是日期。

$scope.searchEventByDate = function (item) {
  var scheduler = $("#scheduler").data("kendoScheduler");
  //scheduler.view().startDate(item.StartDate);
  //scheduler.view().endDate(item.EndDate);
  scheduler.view("day");
  // item.StartDate should be Date object - like scheduler.date(new Date("2013/6/6"));
  scheduler.date(item.StartDate);
  $scope.scheduler.dataSource.read();       
};

如果您需要设置一些明确的日期范围进行过滤 - 您可以这样做,但仍然无法在日视图中显示超过一天。

$scope.searchEventByDate = function (item) {
  var scheduler = $("#scheduler").data("kendoScheduler");
  scheduler._myFilterStartDate = item.StartDate;
  scheduler._myFilterEndDate = item.EndDate;
  scheduler.view("day");
  scheduler.date(item.StartDate);
  $scope.scheduler.dataSource.read();       
};      

在参数图中:

...
return {
  filterByStartDate: scheduler.view().startDate(),
  filterByEndDate: scheduler.view().endDate(),
  myFilterStartDate: scheduler._myFilterStartDate,
  myFilterEndDate: scheduler._myFilterEndDate,
  OrgId: _orgId,
  UserTimezone: global.userTimezoneOffset
};
...