Filtering SignalR datasource

6 posts, 1 answers
  1. Jon
    Jon avatar
    53 posts
    Member since:
    Oct 2013

    Posted 20 Jun 2016 Link to this post

    Hi I have a scheduler that I'm trying to apply dynamic filtering. From my research I found out about parameterMap... I have implemented it as follows...

    In my Scheduler initialisation....

                 dataSource: {
                 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,
                     ParameterMap: "parameterMap",
                     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
                    }
                }
            }

     

    And my parametermap code is:

    function parameterMap(data, type) {
     
            alert(type);
     
            if (type === "read") {
                data.filter = { logic: "and", filters: [{ field: "diary", operator: "eq", value: '@AppShort' }] };
            }
      
            return data;
        }

     

    Where @AppShort is a value that has been derived at the beginning of the view... 

    @Code
        ViewData("Title") = "Home Page"
        Dim AppShort As String
        AppShort = SupportDiary.My.MySettings.Default.AppShort
    End Code

     

     

    Unfortunately the filtering does not work... I get no errors... the scheduler just shows all scheduled events without filtering.

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2190 posts

    Posted 22 Jun 2016 Link to this post

    Hi Jon,

    From the provided information it's not clear for us what is the exact reason for current behavior. Could you please provide runable (and isolated) example where the issue is reproduced? This would help me advice you better how to proceed. 

    Regards,
    Vladimir Iliev
    Telerik
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Jon
    Jon avatar
    53 posts
    Member since:
    Oct 2013

    Posted 22 Jun 2016 in reply to Vladimir Iliev Link to this post

    Hi, have raised support ticket 1045379 with copy of application and data.
  4. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2190 posts

    Posted 23 Jun 2016 Link to this post

    Hi Jon,

    I answered to this query in the duplicated support ticket created by you - #1045379 . Please keep in mind that it is highly recommended that you keep related questions in one support thread or a forum post, so that we can easily keep track of your support history and provide better answers in a shorter time.

    Regards,
    Vladimir Iliev
    Telerik
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  5. Gareth
    Gareth avatar
    2 posts
    Member since:
    May 2015

    Posted 15 Dec 2016 Link to this post

    Hi did you get this working in the end, i have the same problem filtering with signalr  how should this be acheived

    Thanks

    Gareth

  6. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    490 posts

    Posted 16 Dec 2016 Link to this post

    Hi Gareth,

    As this scenario could be of interest to other developers too, I am including below the Vladimir's answer on how to configure filtering and sending additional parameters along with the SignalR Read action:
    //Extending the MyDataSourceRequest from Kendo DynamicLinq:
    public class MyDataSourceRequestExtended : MyDataSourceRequest
    {
        public DateTime start { get; set; }
        public DateTime end { get; set; }
    }

    public DataSourceResult Read(MyDataSourceRequestExtended request)
    {
        return taskService.Read()
            //fiter the events by the provided start / end times
            .Where(t => (t.Start >= request.start || t.Start <= request.start) && t.Start <= request.end && t.End >= request.start && (t.End >= request.end || t.End <= request.end) || t.RecurrenceRule != null)
            //apply the other filters
            .ToDataSourceResult(request.Take, request.Skip, request.Sort, request.Filter, request.Aggregates);
    }
    dataSource: {
        type: "signalr",
        transport: {
            parameterMap: function (data) {
      
                if (operation === "read") {
      
                    var scheduler = $("#scheduler").data("kendoScheduler");
                    var result = {
                        start: scheduler.view().startDate(),
                        end: scheduler.view().endDate(),
                        //example filter:
                        filter: {
                            "logic": "and",
                            "filters": [{
                                "logic": "and",
                                "filters": [{
                                    "field": "UnitPrice",
                                    "operator": "eq",
                                    "value": 10
                                }]
                            }]
                        }
                    }
                    return result;
                }
      
                return data;
            },

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top