This is a migrated thread and some comments may be shown as answers.

Filtering SignalR datasource

5 Answers 196 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 20 Jun 2016, 02:23 PM

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.

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 22 Jun 2016, 08:40 AM
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.
 
0
Jon
Top achievements
Rank 1
answered on 22 Jun 2016, 01:57 PM
Hi, have raised support ticket 1045379 with copy of application and data.
0
Accepted
Vladimir Iliev
Telerik team
answered on 23 Jun 2016, 07:46 AM
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.
 
0
Gareth
Top achievements
Rank 1
answered on 15 Dec 2016, 06:43 PM

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

Thanks

Gareth

0
Veselin Tsvetanov
Telerik team
answered on 16 Dec 2016, 09:49 AM
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.
Tags
Scheduler
Asked by
Jon
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Jon
Top achievements
Rank 1
Gareth
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or