KendoUI Grid Signalr Error - kendo-ui

I am receiving the error "Maximum call stack size exceeded" while trying to bind Signalr data to the KendoUI grid (v2014.1 416).
Here is my current code:
var epConnection = $.hubConnection();
var hub = epConnection.createHubProxy("EventsPendingHub");
var hubStart = epConnection.start();
$('#tblEventsPending').kendoGrid({
sortable: true,
columns: [
{ field: "EventNum" },
{ field: "Area" },
{ field: "Zone" },
{ field: "Priority" },
{ field: "Type" },
{ field: "TIQ" },
{ field: "Location" },
{ field: "Apt"}
],
dataSource: {
type: "signalr",
autoSync: true,
schema: {
model: {
id: "EventNum",
fields: {
"EventNum": { type: "string" },
"Area": { type: "string" },
"Zone": { type: "string" },
"Priority": { type: "string" },
"Type": { type: "string" },
"TIQ": { type: "string" },
"Location": { type: "string" },
"Apt": {type: "string"}
}
}
},
sort: [
{ field: "Priority", dir: "desc"},
{ field: "TIQ", dir: "desc"}
],
transport: {
signalr: {
promise: hubStart,
hub: hub,
server: {
read: "read",
update: "update",
destroy: "destroy",
create: "create"
},
client: {
read: "read",
update: "update",
destroy: "destroy",
create: "create"
}
}
}
}
});
Hub Code:
[HubName("EventsPendingHub")]
public class EventsPendingHub : Hub
{
private readonly EventsPending _eventsPending;
public EventsPendingHub() : this(EventsPending.Instance) {}
public EventsPendingHub(EventsPending eventsPending)
{
_eventsPending = eventsPending;
}
public IEnumerable<EventPending> GetAllEventsPending()
{
return _eventsPending.GetAllEventsPending();
}
}
Startup.cs:
[assembly: OwinStartup(typeof(CADView.Startup))]
namespace CADView
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
app.MapSignalR(hubConfiguration);
}
}
}
The error is being thrown at the client by jQuery...the last line from below is repeated 30+ times.
Uncaught RangeError: Maximum call stack size exceeded
o.extend.isPlainObject jquery-2.1.0.min.js?hash=2258a75c-c461-4821-2436-dfdf3af9bffe:2
o.extend.o.fn.extend jquery-2.1.0.min.js?hash=2258a75c-c461-4821-2436-dfdf3af9bffe:2

I have the similar problem with you and i find out that kendo ui is not compatible with higher version of jQuery.
ex:-jquery-2.1.0.min.js
it is compatible with jquery-1.9.1.min.js
try this you will get rid of this problem.

Related

Kendo Grid disable field during Edit mode

Using kendo grid edit event I want to disable field name and id during Edit mode. I manage to disable id by following this example here. But went I try to disable name seem it not working, any thought how to do this?
WORKING DEMO IN DOJO
$("#grid").kendoGrid({
columns: [
{ field: "id" },
{ field: "name" },
{ field: "age" },
{ command: "edit" }
],
dataSource: {
data: [
{ id: 1, name: "Jane Doe", age: 30 },
{ id: 2, name: "John Doe", age: 33 }
],
schema: {
model: {
id: "id",
fields: {
"id": { type: "number" },
"name": { type: "string" }
}
}
}
},
editable: "inline",
toolbar:["create"],
edit: function(e) {
if (!e.model.isNew()) {
var numeric = e.container.find("input[name=id]").data("kendoNumericTextBox");
numeric.enable(false);
//var x = e.container.find("input[name=name]").data("kendoTextBox");
//x.enable(false);
//$("input[name=name]").prop("disabled", true).addClass("k-state-disabled");
//$("input[name=name]").editable = false;
}
}
});
by using editable function i created this
function isEditable(e){
var dataSource = $("#grid").data("kendoGrid").dataSource;
return (e.id == null || e.id == '');
}
and add this into the grid > column
columns: [
{ field: "id", editable: isEditable },
{ field: "name", editable: isEditable },
{ field: "age" },
{ command: "edit" }
],
Full working demo is here

Kendo Grid Server side filtering with a array type column

I have this kendo grid blinded to my web service. One of the columns has a custom filter with a kendo multiselector array so the client can choose multiple ItemTypes. The grid is displaying data correctly but my costume filters are not working for this particular column. I got this error from the service: "A binary operator with incompatible types was detected. Found operand types 'Telerik.Sitefinity.DynamicTypes.Model.ClinicFinder.Clinic.ItemType.ItemType' and 'Edm.Int32' for operator kind 'Equal'."
My grid definition
$("#grid").kendoGrid({
dataSource: {
type: "odata-v4",
transport: {
read: {
url: function () {
return "//myservice/api/clinics?$select=Id,Title,Address,ItemType,productsystems&top=20";
}
}
},
schema: {
model: {
fields: {
Title: { type: "string" },
CountryCode: { type: "string" },
Street: { type: "string" },
City: { type: "string" },
Zip: { type: "string" },
ItemType: { type: "" }
}
}
},
serverPaging: true,
serverFiltering: true,
serverSorting: false,
pageSize: 20
},
pageable: true,
filterable: {
mode: "row",
extra: false,
showOperators: false,
operators: {
string: {
contains: "contains"
}
}
},
sortable: false,
columns: [
{ field: "Title", title: "Clinic" },
{ field: "CountryCode", title: "Country" },
{ field: "Street", title: "Address" },
{ field: "City", title: "City" },
{ field: "Zip", title: "Zip", filterable: false },
{ field: "ItemType", title: "Clinic Type", filterable: { multi: true } }
],
rowTemplate: kendo.template($("#template").html())
});
My Filter function
function filterByclinicCategory() {
var filter = { logic: "or", filters: [] };
var grid = $('#grid').data('kendoGrid');
var filterValue = $("#clinicTypeFilter").data("kendoMultiSelect").value();
var clinicCode = [];
if (filterValue.length > 0) {
$.each(filterValue, function (i, v) {
clinicCode.push(convertClinicTypesInCodes(v));
filter.filters.push({
field: "ItemType", operator: "eq", value: clinicCode, logic: "or"
});
grid.dataSource.filter(filter);
});
} else {
$("#grid").data("kendoGrid").dataSource.filter({});
}
}
ItemType is the column I canĀ“t filter.
My webservice data
{
"#odata.context": "https://sf-admin-local.medel.com/api/wstest/$metadata#clinics(*)",
"value": [
{
"Id": "896aa08b-2f17-64e6-80bd-ff09000c6e28",
"LastModified": "2019-05-13T09:28:04Z",
"PublicationDate": "2018-06-19T14:19:13Z",
"DateCreated": "2018-06-19T14:19:13Z",
"UrlName": "??",
"Email": "",
"URL": "",
"Telephone": "",
"Title": "????????",
"officeregions": [],
"salespartnerregions": [],
"productsystems": [
"b8ec2a8b-2f17-64e6-80bd-ff09000c6e28",
"1878cb61-ac79-69d9-867b-ff01007297b6",
"1b78cb61-ac79-69d9-867b-ff01007297b6",
"36d8938b-2f17-64e6-80bd-ff09000c6e28"
],
"Area": "",
"Order": 0,
"Tags": [],
"AdditionalInformation": "",
"ImportID": 1,
"Featured": false,
"ItemType": "2",
"Address": {
"Id": "d76aa08b-2f17-64e6-80bd-ff09000c6e28",
"CountryCode": "AT",
"StateCode": "",
"City": "????",
"Zip": "6800",
"Street": "Carinagasse ?????",
"Latitude": 47.2311043,
"Longitude": 9.580079999999953,
"MapZoomLevel": 8
}
}
]
}
I manage to fix it using parameterMap https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.parametermap.
I add a parameterMap: functiondata, type) function, with that I was able to intercept and change the call made by the filters.
parameterMap: function (data, type) {
var c = kendo.data.transports["odata-v4"].parameterMap(data, type);
if (c.$filter) {
//my transformation
c = myTransformation;
return c;
} else{
return c; //not apply transformation loading the data
}
}

filtering kendo ui scheduler

I have a scheduler and a dropdown in a diary app. The scheduler is configured as such:
$("#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
}
}
},
},
}
});
I am trying to use parameterMap to filter the data based on one or two bits of data.
If the dropdown value = ALL then the data is filtered by diary =
#AppShort where #AppShort is derived from the web.config settings
section.
If the dropdown value = MY then the data is further filtered to just
display the current uses events
If the dropdown value is anything else then that means a team name is
selected and so the data is filtered by diary and team.
My problem is that the data is not filtered at all and the parameterMap function is never triggered. Is this the best approach or is there another way of implementing filtering.
Any help appreciated.
UPDATE
As requested... this is my signalR hub code:
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
And this is my SchedulerRequestService class...
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
UPDATE 2
With some help from Calinaadi and examples of filtering a SignalR datasource on a Kendo Grid I can see that I need to modify my read function to accept my filter(s). Unfortunately the examples used with the grid had .take, .skip, .sort, .filter and .aggregate as paramenters which I understand when you have a grid with paging and you want to take X records after skipping Y records.
This is a typical example from telerik demos...
public DataSourceResult Read(MyDataSourceRequest request)
{
return productService.Read().ToDataSourceResult(request.Take, request.Skip, request.Sort, request.Filter, request.Aggregates);
}
For a scheduler I would expect a read to fetch back all events with an end on or after the start of the current scheduler view and a start on or before the end of the current scheduler view. Probably sorted by start. Filtered by the field filters is necessary (these are the filters I've set). I can't see take, skip or aggregate have any concept in fetching event data.
My app function completely apart from the filtering. I have a VS solution I can share if necessary with database populated with dummy records.
Offering a bounty for any help.
You should change:
transport: {
signalr: {
hub: sHub,
promise: sHubStart,
ParameterMap: "parameterMap",
to:
transport: {
parameterMap: function parameterMap(data, type) {
alert(type);
},
signalr: {
After many searches and much reading. I now have a working system. The scheduler required the parameter serverFiltering: true also the Read, Create, Update and Destroy functions has to be redone to accept the filter that was posted. If anyone would like a copy of the code which is a tad too much to post here I can let you have it.

Display the popup view when the filtering is under process

In my group's project, we had a one grid and export button. We came across an issue which is that when exopt the data in excel format fiddle: http://jsfiddle.net/SZBrt/11/ need to display the pop up message stating that 'The data is getting filtered' to be displayed so that the we can know the filtering is under process. I appreciate your help in advance.
And My Code:
var grid = $("#grid").kendoGrid({
dataSource: {
type : "odata",
transport : {
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema : {
model: {
fields: {
OrderID : { type: "number" },
Freight : { type: "number" },
ShipName : { type: "string" },
OrderDate: { type: "date" },
ShipCity : { type: "string" }
}
}
},
pageSize : 10
},
filterable: true,
sortable : true,
pageable : true,
columns : [
{
field : "OrderID",
filterable: false
},
"Freight",
{
field : "OrderDate",
title : "Order Date",
width : 100,
format: "{0:MM/dd/yyyy}"
},
{
field: "ShipName",
title: "Ship Name",
width: 200
},
{
field: "ShipCity",
title: "Ship City"
}
]
}).data("kendoGrid");
Add to the DataSource definition an event handler for requestStart and requestEnd.
dataSource: {
requestStart : function() {
// Add code for displaying your own "loading" message
},
requestEnd: function() {
// Add code for hiding your own "loading" message
},
type : "odata",
transport : {
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema : {
model: {
fields: {
OrderID : { type: "number" },
Freight : { type: "number" },
ShipName : { type: "string" },
OrderDate: { type: "date" },
ShipCity : { type: "string" }
}
}
},
pageSize : 10
},
You did not specify how that Loading message looks like, it might be as simple as adding / removing visibility:
requestStart: function () {
$("#loading-msg").css("visibility", "visible");
},
requestEnd: function () {
$("#loading-msg").css("visibility", "hidden");
},
or open / close a window:
requestStart: function () {
$("#loading-msg").data("kendoWindow").center().open();
},
requestEnd: function () {
$("#loading-msg").data("kendoWindow").close();
},

Kendo UI Grid not loading data from datasource

I am new on kendo UI framework. I am struggling with observable datasource with kendoGrid.
The problem is the table gets created but with empty data.
Here is the link http://jsfiddle.net/praveeny1986/Pf3TQ/5/
And the code :
var gridDataModel = kendo.data.Model.define({
fields: {
"Product": {
type: "string"
},
"Domain": {
type: "string"
},
"PercentPlan": {
type: "string"
},
"CWV": {
type: "string"
},
"Target": {
type: "string"
},
"Accuracy": {
type: "string"
}
}
});
var dataSource = new kendo.data.DataSource({data: tabledata1});
var gridModel = kendo.observable({
gridData: dataSource
});
kendo.bind($("#chart"),gridModel);
$("#chart").kendoGrid({
scrollable:false,
dataSource:gridModel.get('gridData'),
height:600,
autoBind:true,
columns:[
{
field: "Product",
title: "Product"
},
{
field: "Domain",
title: "Sales Domain"
},
{
field: "PercentPlan",
title: "% to Plan"
},
{
field: "CWV",
title: "CWV"
},
{
field: "Target",
title: "Target"
},
{
field: "Accuracy",
title: "Accuracy"
}]
});
var tabledata1 = [
{
Product:"mobile",
Domain:"SMARTPHONES-EAST",
PercentPlan:"95",
CWV:"160",
Target:"200",
Accuracy:"9"
},
{
Product:"mobile",
Domain:2,
PercentPlan:"80",
CWV:"160",
Target:"200",
Accuracy:"8.5"
},
{
Product:"mobile",
Domain:3,
PercentPlan:"75",
CWV:"150",
Target:"200",
Accuracy:"8"
},
{
Product:"mobile",
Domain:4,
PercentPlan:"60",
CWV:"120",
Target:"200",
Accuracy:"6"
},
{
Product:"mobile",
Domain:5,
PercentPlan:"50",
CWV:"150",
Target:"300",
Accuracy:"5"
}
];
Please suggest what i am doing wrong ?
Thanks in advance
Your table data is undefined at the time that you create and bind the datasource.
var dataSource = new kendo.data.DataSource({data: tabledata1});
var tabledata1 = [ ... ];
Move the declaration of tabledata1 to before creating the datasource.
See this updated fiddle.
http://jsfiddle.net/nukefusion/Pf3TQ/7/

Resources