I have a grid on an MVC page, I have an error event as follows:
.DataSource(dataSource => dataSource
.Ajax()
.Batch(false)
.PageSize(50)
.Events(events => events.Error("gridErrorHandler"))
My JavaScript function is something like:
function gridErrorHandler(e) {
...
}
I have an MVC method (that returns ActionResult) that throws the following error when an error condition occurs:
return new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError, "Unexpected error");
My question is this. When my MVC method throws an exception, my JS error handler gets called. But, no matter what I try, I'm not able to get at the type of error it is. What exactly is the correct JS code that tells me a 500 error occurred, or a 401 (unauthorized) error occurred, etc.?
@model VentSettings
<
div
class
=
"k-toolbar k-grid-toolbar"
>
<
a
class
=
"k-button k-button-icontext k-add-button"
href
=
"#"
><
span
class
=
"k-icon k-add"
></
span
>Add new record</
a
>
</
div
>
<
script
type
=
"text/x-kendo-tmpl"
id
=
"ventTemplate"
>
<
div
>
<
div
class
=
"edit-buttons"
style
=
"width:98%; background:lightgray; border:1px solid lightgray; padding:10px;"
>#:Time#
<
a
style
=
"float:right"
class
=
"k-button k-button-icontext k-edit-button"
href
=
"\\#"
><
span
class
=
"k-icon k-edit"
></
span
>Edit</
a
>
<
a
style
=
"float:right"
class
=
"k-button k-button-icontext k-delete-button"
href
=
"\\#"
><
span
class
=
"k-icon k-delete"
></
span
>Delete</
a
>
</
div
>
<
div
style
=
"width: 98%; padding:10px; border:1px solid lightgray;"
>
<
span
style
=
"width:10%; display: inline-block"
>Rate:</
span
><
span
style
=
"width:22%; display:inline-block"
>#:Rate# per min</
span
>
<
span
style
=
"width:10%; display: inline-block"
>PIP:</
span
><
span
style
=
"width:22%; display:inline-block"
>#:PIP# cm H<
sub
>2</
sub
>O</
span
>
<
span
style
=
"width:10%; display: inline-block"
>PEEP:</
span
><
span
style
=
"width:22%; display:inline-block"
>#:PEEP# cm H<
sub
>2</
sub
>O</
span
>
<
span
style
=
"width:10%; display: inline-block"
>MAP:</
span
><
span
style
=
"width:22%; display:inline-block"
>#:MAP# cm H<
sub
>2</
sub
>O</
span
>
<
span
style
=
"width:10%; display: inline-block"
>Vent:</
span
><
span
style
=
"width:50%; display:inline-block"
>#:VentDescription# </
span
>
</
div
>
</
div
>
</
script
>
@(Html.Kendo().ListView<
VentSetting
>(Model.VentSettingsList)
.Name("listView")
.TagName("div")
.ClientTemplateId("ventTemplate")
.Editable()
.DataSource(datasource => datasource
.Events(events => events.Sync("handleSync"))
.Model(model => model.Id(m => m.VentSettingId))
.Read(read => read.Action("ReadVentSettings", "RunDetail"))
.Create(create => create.Action("CreateVentSetting", "RunDetail"))
.Update(update => update.Action("UpdateVentSetting", "RunDetail"))
.Destroy(destroy => destroy.Action("DeleteVentSetting", "RunDetail"))
)
)
<
script
>
function handleSync() {
this.read();
}
</
script
>
<
div
style
=
"padding:10px"
>
@Html.ValidationSummary(true)
<
span
style
=
"width:12%; display:inline-block"
>Resp Rate: </
span
>
<
span
style
=
"width:36%; display:inline-block"
> @Html.Kendo().DropDownListFor(x => x.VentTypeId).DataValueField("VentTypeId").DataTextField("Description").BindTo((System.Collections.IEnumerable)ViewData["VentTypes"])</
span
>
<
div
class
=
"edit-buttons"
>
<
a
class
=
"k-button k-button-icontext k-update-button"
href
=
"\\#"
><
span
class
=
"k-icon k-update"
></
span
>Save</
a
>
<
a
class
=
"k-button k-button-icontext k-cancel-button"
href
=
"\\#"
><
span
class
=
"k-icon k-cancel"
></
span
>Cancel</
a
>
</
div
>
</
div
>
[HttpPost]
public ActionResult CreateVentSetting([DataSourceRequest] DataSourceRequest request, Models.VentSetting modelVentSetting)
{
if (modelVentSetting != null && ModelState.IsValid)
{ // Create code... }
return Json(ModelState.ToDataSourceResult());
}
[HttpPost]
public ActionResult UpdateVentSetting([DataSourceRequest] DataSourceRequest request, Models.VentSetting modelVentSetting)
{
// Update code...
return Json(ModelState.ToDataSourceResult());
}
Hi,
Does the chart have a single property where I can set the font-family for all of the text elements (title, legend, tooltip, axis label, axis title, etc) that the chart may contain?
I'd like to apply our fonts to charts but not have to set half a dozen or more properties if it can be avoided.
Thanks!
Hey,
I'm currently trying to use batch syncing with the server using the DataSource's transport.submit handler. The documentation tells me to pass a method, and to set batch to true on the DataSource itself in order to work properly. To my surprise I'm facing an exception with the following stacktrace:
Uncaught TypeError: Cannot read property 'data' of undefined
at init.setup (VM3012 kendo.all.min.js:27)
at init.update (VM3012 kendo.all.min.js:27)
at Object.<
anonymous
> (VM3012 kendo.all.min.js:27)
at Function.Deferred (VM2971 jquery.min.js:2)
at init._promise (VM3012 kendo.all.min.js:27)
at init._send (VM3012 kendo.all.min.js:27)
at init.sync (VM3012 kendo.all.min.js:27)
at init.saveChanges (VM3012 kendo.all.min.js:50)
at HTMLAnchorElement.<
anonymous
> (VM3012 kendo.all.min.js:50)
at HTMLDivElement.dispatch (VM2971 jquery.min.js:3)
A workaround would be to set the method after grid initialization (code below), but I'm wondering what could be wrong with my initial syntax/code.
var grid = $("#grid").data("kendoGrid");
grid.dataSource.transport.submit = function(e) { alert("alternate submit"); };
Reproduction (DoJo): Try to (inline) edit a row, then press 'save changes', using the code below:
<!DOCTYPE html>
<
html
>
<
head
>
<
base
href
=
"http://demos.telerik.com/kendo-ui/grid/editing"
>
<
style
>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</
style
>
<
title
></
title
>
<
link
rel
=
"stylesheet"
href
=
"https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.common-material.min.css"
/>
<
link
rel
=
"stylesheet"
href
=
"https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.material.min.css"
/>
<
link
rel
=
"stylesheet"
href
=
"https://kendo.cdn.telerik.com/2017.2.621/styles/kendo.material.mobile.min.css"
/>
<
script
src
=
"https://kendo.cdn.telerik.com/2017.2.621/js/jquery.min.js"
></
script
>
<
script
src
=
"https://kendo.cdn.telerik.com/2017.2.621/js/kendo.all.min.js"
></
script
>
</
head
>
<
body
>
<
div
id
=
"example"
>
<
div
id
=
"grid"
></
div
>
<
script
>
$(document).ready(function () {
var crudServiceBaseUrl = "https://demos.telerik.com/kendo-ui/service",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/Products",
dataType: "jsonp"
},
submit: function(e) {alert("submit"); }
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
UnitPrice: { type: "number", validation: { required: true, min: 1} },
Discontinued: { type: "boolean" },
UnitsInStock: { type: "number", validation: { min: 0, required: true } }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: [
"ProductName",
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: 120 },
{ field: "UnitsInStock", title: "Units In Stock", width: 120 },
{ field: "Discontinued", width: 120, editor: customBoolEditor },
{ command: "destroy", title: " ", width: 150 }],
editable: true
});
/*
Workaround:
var grid = $("#grid").data("kendoGrid");
grid.dataSource.transport.submit = function(e) { alert("alternate submit"); };
*/
});
function customBoolEditor(container, options) {
$('<
input
class
=
"k-checkbox"
type
=
"checkbox"
name
=
"Discontinued"
data-type
=
"boolean"
data-bind
=
"checked:Discontinued"
>').appendTo(container);
$('<
label
class
=
"k-checkbox-label"
></
label
>').appendTo(container);
}
</
script
>
</
div
>
</
body
>
</
html
>
Kind regards
Using this example https://demos.telerik.com/kendo-ui/dropdownlist/addnewitem and changing the kendoDropDownList to kendoMultiSelect, i receive the error below because the instance.filterInput is not defined on the widget instance. According to your docs these two property configurations are supported. How can I get the multiSelect to have a filter?
DOCS
http://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect#configuration-filter
http://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect#configuration-noDataTemplate
ERROR
Uncaught TypeError: Cannot read property 'val' of undefined
at init.eval [as noDataTemplate] (eval at compile (kendo.all.js:194), <anonymous>:3:196)
at init._renderNoData (kendo.all.js:27300)
at init._listBound (kendo.all.js:33923)
at init.d (jquery.min.js:2)
at init.trigger (kendo.all.js:124)
at init.refresh (kendo.all.js:28807)
at init.d (jquery.min.js:2)
at init.trigger (kendo.all.js:124)
at init._process (kendo.all.js:6965)
at init.success (kendo.all.js:6710)