Hi,
I have a view with 4 kendo grids (Version 2013.1.514 MVC complete) doing different functions for the user and I have a central mechanism to handle all errors from all the grids of the application.
Grid Configuration
Error Handler
I could verify that the kgrid is object but databinding event is not triggered in a view with multiple grids.
Any help is highly appreciated!!!
Thanks,
I have a view with 4 kendo grids (Version 2013.1.514 MVC complete) doing different functions for the user and I have a central mechanism to handle all errors from all the grids of the application.
Grid Configuration
@(Html.Kendo().Grid<
NewAlta.DataCapture.DataModel.ParameterOverride
>()
.Name("test")
.Columns(columns =>
{
columns.Bound(p => p.CustomerId).Hidden();
columns.ForeignKey(p => p.EquipmentId, (System.Collections.IEnumerable)ViewData["equipments"], "EquipmentId", "Description").Title("Equipment").EditorTemplateName("CustomerEquipmentId");
columns.ForeignKey(p => p.ParameterId, (System.Collections.IEnumerable)ViewData["parameters"], "ParameterId", "ParameterName").Title("Parameter").EditorTemplateName("ParameterId");
columns.Bound(p => p.Limit1).Width(100);
columns.Bound(p => p.Limit2).Width(200);
columns.Bound(p => p.Limit3).Width(200);
columns.Bound(p => p.Limit4).Width(100);
columns.Command(p => p.Edit()).Width(80);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.AutoBind(false)
// .Navigatable(builder => builder.Enabled(true))
.Events(events =>
{
events.Change("test");
events.Edit("test");
events.Save("test");
})
.Selectable(builder => builder.Mode(GridSelectionMode.Single))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Events(e => e.Error("errorHandler"))
// omitted for brevity
<
script
type
=
"text/javascript"
>
function errorHandler(e) {
gridErrorHandler(e, "#test");
}
//The below function lies in some js include files.
function gridErrorHandler(args, gridId) {
if (args.errors) {
var message = "We have encountered following errors : \n <
ul
>";
$.each(args.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
//alert(this);
if (this != "" && this != null)
message += "<
li
>" + this + "</
li
> \n ";
});
message += "</
ul
>";
}
});
var kgrid = $(gridId).data("kendoGrid");
kgrid.one('dataBinding', function (e) { //==> if we have only one grid in the view this works. for mutiple grids in view it does not trigger
e.preventDefault(); // cancel grid rebind if error occurs
});
showAlertWindow(message); //==> Some other function used to show kendo window with errror messages.
}
}
</
script
>
Any help is highly appreciated!!!
Thanks,