过滤kendo ui调度程序

时间:2016-06-22 14:42:50

标签: kendo-ui kendo-scheduler

我在日记应用中有一个调度程序和一个下拉列表。调度程序配置如下:

       $("#scheduler").kendoScheduler({
            date : Date.now(),
            workDayStart: new Date("2015/1/1 08:00 AM"),
            workDayEnd: new Date("2015/1/1 8:00 PM"),
            dateHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'ddd dd/M')#</strong>"),
            majorTimeHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'HH')#</strong><sup>00</sup>"),
            minorTimeHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'HH')#</strong><sup>#=kendo.toString(date, 'mm')#</sup>"),
            selectable: true,
            messages: {
                ariaSlotLabel: "Selected from {0:g} to {0:g}",
                showWorkDay: "Show core work hours"
            },
            editable: {
                window: {
                    title: "Work Request Details",
                    width: "800px"
                },
                template: $("#customEditorTemplate").html()
            },
            edit: function (e) {
                //set the start end datetime
                if (e.event.isNew && e.event.id == -1) {
                    var startDtp = e.container.find("[name=start][data-role=datetimepicker]");
                    var endDtp = e.container.find("[name=end][data-role=datetimepicker]");
                    var setStartDate = e.event.start;
                    var setEndDate = e.event.end;
                    setStartDate.setHours(8);
                    setEndDate.setHours(-6); // by default the end date is midnight on the following day of the selected cell so we subtract 6h to get 18:00 on the selected date.
                    $(startDtp).data("kendoDateTimePicker").value(setStartDate); //set start date to the selected cell start date and time 08:00
                    $(endDtp).data("kendoDateTimePicker").value(setEndDate); //set enddate to the selected cell end date and time 18:00
                }

                var recurrenceEditor = e.container.find("[data-role=recurrenceeditor]").data("kendoRecurrenceEditor");
                //set start option value, used to define the week 'Repeat on' selected checkboxes
                recurrenceEditor.setOptions({
                start: new Date(e.event.start)
                });
            },
            eventTemplate: $("#eventTemplate").html(),
            height: 550,
            messages: {
                allDay: "Anytime"
            },
            views: [
                { type: "day", allDaySlot: true},
                { type: "week", eventHeight: 80 },
                { type: "timeline", eventHeight: 80 },
                { type: "timelineWeek", selected: true, majorTick: 1440, minorTickCount: 1, eventHeight: 80 },
                { type: "agenda" },
                { type: "month", eventHeight: 80 }
            ],
            timezone: "Etc/UTC",
            selectable: true,
            dataSource: {
                parameterMap: function parameterMap(data, type) {
                    console.log(type);
                    if (type === "read") {
                        //var reqFilter = wRequestFilter.value();
                        var reqFilter = 'ALL'
                        console.log(reqFilter);
                        if (reqFilter == "MY") {
                            data.filter = { logic: "and", filters: [{ field: "diary", operator: "eq", value: 'UIS' }, { field: "AssigneeID", operator: "eq", value: 1 }] };
                        } else if (reqFilter == "ALL") {
                            data.filter = { logic: "and", filters: [{ field: "diary", operator: "eq", value: 'UIS' }] };
                        } else {
                            data.filter = { logic: "and", filters: [{ field: "diary", operator: "eq", value: 'UIS' }, { field: "team", operator: "eq", value: reqFilter }] };
                        }

                    }
                    console.log(data);
                    return data;
                },
                type: "signalr",
                push: function (e) {
                    generateNotification(e.type, e.items[0].WRequestID, e.items[0].diary, e.items[0].team);
                },
                transport: {
                    signalr: {
                        hub: sHub,
                        promise: sHubStart,
                        server:   {
                            read: "read",
                            create: "create",
                            update: "update",
                            destroy: "destroy"
                        },
                        client: {
                            read: "read",
                            create: "create",
                            update: "update",
                            destroy: "destroy"
                        }
                    },
                },
                schema: {
                    model: {
                        id: "WRequestID",
                        fields: {
                            WRequestID: {
                                type: "number",
                                editable: false,
                                defaultValue: -1
                            },
                            start: {
                                from: "Start",
                                type: "date",
                                culture: "en-GB"
                            },
                            end :   {
                                from: "End",
                                type: "date",
                                culture: "en-GB" },
                            diary: {
                                from: "Diary",
                                type: "string",
                                defaultValue: "@AppShort"
                            },
                            team: {
                                from: "Team",
                                type: "string",
                                validation: { required: true }
                            },
                            title: {
                                from: "Title",
                                type: "string",
                                validation: { required: true }
                            },
                            workManager: {
                                from: "WorkManagerID",
                                type: "number",
                                validation: { required: true }
                            },
                            assignee: {
                                from: "AssigneeID",
                                type: "number",
                                validation: { required: true }
                            },
                            changeRef: {
                                from: "ChangeRef",
                                type: "string",
                                validation: { required: true }
                            },
                            description: {
                                from: "Description",
                                type: "string",
                                validation: { required: true }
                            },
                            impactedServers: {
                                from: "ImpactedServers",
                                type: "string",
                                validation: { required: true }
                            },
                            impactedServices: {
                                from: "ImpactedServices",
                                type: "string",
                                validation: { required: true }
                            },
                            isBAU: {
                                from: "IsBAU",
                                type: "boolean",
                                defaultValue: false
                            },
                            projectRef: {
                                from: "ProjectRef",
                                type: "string",
                                validation: { required: true }
                            },
                            notes: {
                                from: "Notes",
                                type: "string"
                            },
                            isOOH: {
                                from: "IsOOH",
                                type: "boolean",
                                defaultValue: false
                            },
                            isAllDay: {
                                from: "IsAllDay",
                                type: "boolean",
                                defaultValue: false
                            },
                            recurrenceRule: {
                                from: "RecurrenceRule",
                                type: "string"
                            },
                            recurrenceId: {
                                from: "RecurrenceID",
                                type: "number"
                            },
                            recurrenceException: {
                                from: "RecurrenceException",
                                type: "string"
                            },
                            startTimezone: {
                                from: "StartTimezone",
                                type: "string"
                            },
                            endTimezone: {
                                from: "EndTimezone",
                                type: "string"
                            },
                            requestStatus: {
                                from: "RequestStatus",
                                type: "number",
                                defaultValue: 0
                            }
                        }
                    },
                },
            }
        });

我正在尝试使用 parameterMap 根据一位或两位数据过滤数据。

  • 如果下拉值= ALL,则数据将通过diary =过滤 @AppShort其中@AppShort派生自web.config设置 部分。
  • 如果下拉值= MY,则数据将进一步过滤为just 显示当前使用事件
  • 如果下拉值是其他任何内容,则表示团队名称为 选中,因此数据由日记和团队过滤。

我的问题是根本没有过滤数据,并且从不触发parameterMap函数。这是最好的方法,还是有另一种实现过滤的方法。

任何帮助表示感谢。

更新

根据要求......这是我的signalR集线器代码:

    Public Class WRequestHub
    Inherits Hub

    Private requestService As SchedulerRequestService

    Public Sub New()
        requestService = New SchedulerRequestService()
    End Sub

    Public Function Read() As IEnumerable(Of WRequestViewModel)
        Return requestService.GetAll()
    End Function

    Public Sub Update(request As WRequestViewModel)
        requestService.Update(request)
        Clients.Others.update(request)
    End Sub

    Public Sub Destroy(request As WRequestViewModel)
        requestService.Delete(request)
        Clients.Others.destroy(request)
    End Sub

    Public Function Create(request As WRequestViewModel) As WRequestViewModel

        requestService.Insert(request)
        Clients.Others.create(request)

        Return request

    End Function

    Public Sub LockRecord(id As Integer)
        Clients.Others.lockRecord(New With {
            Key .id = id
        })
    End Sub

    Public Sub UnlockRecord(id As Integer)
        Clients.Others.unlockRecord(New With {
            Key .id = id
        })
    End Sub

End Class

这是我的SchedulerRequestService类......

    Public Class SchedulerRequestService

    Public Overridable Function GetAll() As IQueryable(Of WRequestViewModel)

        Using de As New SupportDiaryEntities

            Dim rList As IQueryable(Of WRequestViewModel)

            rList = (From r In de.tWorkRequests
                     Select New WRequestViewModel() With {
                        .WRequestID = r.WRequestID,
                        .Start = r.Start,
                        .[End] = r.[End],
                        .Title = r.Title,
                        .Diary = r.Diary,
                        .Team = r.Team,
                        .WorkManagerID = r.WorkManagerID,
                        .AssigneeID = r.AssigneeID,
                        .ChangeRef = r.ChangeRef,
                        .Description = r.Description,
                        .ImpactedServers = r.ImpactedServers,
                        .ImpactedServices = r.ImpactedServices,
                        .IsBAU = r.IsBAU,
                        .ProjectRef = r.ProjectRef,
                        .Notes = r.Notes,
                        .IsOOH = r.IsOOH,
                        .IsAllDay = r.IsAllDay,
                        .RecurrenceRule = r.RecurrenceRule,
                        .RecurrenceID = r.RecurrenceID,
                        .RecurrenceException = r.RecurrenceException,
                        .StartTimezone = r.StartTimezone,
                        .EndTimezone = r.EndTimezone,
                        .RequestStatus = r.RequestStatus
                    }).ToList.AsQueryable()

            Return rList

        End Using

    End Function

        'OTHER FUNCTIONS (Insert, Update, Delete) Removed for brevity.
    End Class

更新2

在Calinaadi的帮助下以及在Kendo Grid上过滤SignalR数据源的示例中,我可以看到我需要修改我的读取函数以接受我的过滤器。不幸的是,与网格一起使用的例子有.take,.skip,.sort,.filter和.aggregate作为参数,我知道当你有一个带分页的网格时你想要在跳过Y记录后获取X记录。

这是来自telerik demos的一个典型例子......

    public DataSourceResult Read(MyDataSourceRequest request)
{
    return productService.Read().ToDataSourceResult(request.Take, request.Skip, request.Sort, request.Filter, request.Aggregates);
}

对于调度程序,我希望读取在当前调度程序视图启动时或之后以及当前调度程序视图结束时或之前的结束时取回所有事件。可能按开始排序。由字段过滤器过滤是必要的(这些是我设置的过滤器)。我无法看到take,skip或aggregate在获取事件数据时有任何概念。

我的应用功能完全不同于过滤功能。我有一个VS解决方案,如果需要,我可以与填充虚拟记录的数据库共享。

为任何帮助提供赏金。

2 个答案:

答案 0 :(得分:3)

你应该改变:

transport: {
                    signalr: {
                        hub: sHub,
                        promise: sHubStart,
                        ParameterMap: "parameterMap",

为:

transport: {
                       parameterMap: function parameterMap(data, type) {
                                                            alert(type);    
                                },
                        signalr: {

答案 1 :(得分:1)

经过多次搜索和阅读。我现在有一个工作系统。调度程序需要参数serverFiltering: true,还必须重做Read, Create, Update and Destroy函数才能接受已发布的过滤器。如果有人想要在这里发布的代码副本太多了,我可以让你拥有它。