I am using kendo grid with signalr push updates.
I also have code for server filtering and paging working.
It all works apart from when a filter menu is open and a push update occurs. I have code intended to prevent the update and data binding - however it isn't preventing the filter menu getting reset and any filter text being cleared.
Thanks in advance..
var
hubUrl =
"/signalr"
;
var
connectionGrid = $.hubConnection(hubUrl, { useDefaultPath:
false
});
var
hubGrid = connectionGrid.createHubProxy(
"eventAlertsHub"
);
var
hubGridStart = connectionGrid.start();
////////////////////////////////////////////////
// Kendo grid
$(
"#grid"
).kendoGrid({
dataSource: {
push: onPush,
type:
"signalr"
,
transport: {
signalr: {
promise: hubGridStart,
hub: hubGrid,
server: {
read:
"read"
},
client: {
read:
"read"
,
update:
"update"
,
destroy:
"destroy"
,
create:
"create"
}
}
},
schema: {
data:
"Data"
,
total:
"Total"
,
model: {
id:
"id"
,
fields: {
id: {
editable:
false
,
nullable:
true
},
LogTime: { type:
"date"
},
OperatingMode: { type:
"string"
},
StatusDescription: { type:
"string"
},
LogSeverity: { type:
"number"
},
MessageSource: { type:
"string"
},
MessageSourceDetails: { type:
"string"
}
}
}
},
sort: { field:
"LogTime"
, dir:
"desc"
},
pageSize: 20,
serverPaging:
true
,
serverFiltering:
true
,
serverSorting:
false
},
filterable:
true
,
sortable:
true
,
pageable:
true
,
scrollable:
true
,
height: 180,
columns: [{
field:
"LogTime"
,
width:
"150px"
,
title:
"Timestamp"
,
format:
"{0:dd/MM/yyyy HH:mm:ss}"
,
filterable: {
ui:
"datetimepicker"
}
}, {
field:
"MessageSource"
,
width:
"10%"
,
title:
"Source"
,
values: [
{ text:
"DATA_BROKER"
, value:
"DATA_BROKER"
},
{ text:
"RULES_ENGINE"
, value:
"RULES_ENGINE"
},
{ text:
"UI_SUBSYSTEM"
, value:
"UI_SUBSYSTEM"
},
{ text:
"DATA_PUBLISHER"
, value:
"DATA_PUBLISHER"
}
],
}, {
field:
"MessageSourceDetails"
,
width:
"15%"
,
title:
"Source Details"
,
filterable:
false
}
,{
field:
"OperatingMode"
,
title:
"Status"
,
width:
"10%"
,
values: [
{ text:
"STARTUP"
, value:
"STARTUP"
},
{ text:
"INITIALISATION"
, value:
"INITIALISATION"
},
{ text:
"NORMAL"
, value:
"NORMAL"
},
{ text:
"STOPPING"
, value:
"STOPPING"
}
],
}, {
field:
"StatusDescription"
,
width:
"55%"
,
title:
"Message"
,
filterable:
false
}, {
field:
"LogSeverity"
,
width:
"10%"
,
values: [
{ text:
"DEBUG"
, value: 1 },
{ text:
"INFO"
, value: 2 },
{ text:
"WARN"
, value: 3 },
{ text:
"ERROR"
, value: 4 },
{ text:
"FATAL"
, value: 5 }
],
title:
"Severity"
}
]
});
function
onPush(e) {
console.log(
"Push update received type = "
+ e.type);
//var notification = $("#notification").data("kendoNotification");
//notification.success(e.type);
//var dataSource = $grid.dataSource;
// Check if a filter menu is open. If so, prevent binding, for binding will interfere with everyting typed in the filter
//var $filtermenu = $(".k-filter-menu");
if
($(
'.k-animation-container'
).is(
":visible"
)) {
console.log(
"Filter is open push update binding cancelled "
);
e.preventDefault();
}
//if (e.type === "create") {
// // Sort grid programmatically
// dataSource.sort(dataSource._sort);
//}
};
$(
"#grid"
).data(
'kendoGrid'
).bind(
"dataBinding"
,
function
(e) {
console.log(
"Binding"
);
// Check if a filter menu is open. If so, prevent binding, for binding will interfere with everyting typed in the filter
if
($(
'.k-animation-container'
).is(
":visible"
)) {
e.preventDefault();
console.log(
"Prevent binding"
);
}
});