or
var grid = $("#MyKendoGrid").data("kendoGrid");var data = grid.dataSource.data();$.each(data, function (i, row) { //do something });Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
Response.ContentEncoding = Encoding.UTF8; Response.ContentType = "application/json; charset=utf-8";
return Json(myResponse, Response.ContentType, Response.ContentEncoding);
// for IE responseText if (Request.Browser.IsBrowser("IE")) { Response.StatusCode = (int)System.Net.HttpStatusCode.OK; Response.ContentType = "text/html; charset=utf-8"; } // End of
Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; and my js handler look like thatfunction onUploadSuccess(e) { //alert("Success (" + e.operation + ") :: " + getFileInfo(e)); if (e.response.Rc != 'OK') addFileRow(e.files[0].name, e.response.ErrorMessages, e.response.CurrentTime, "uploadRowError", ""); else { var runCmd = "<div .... />"; addFileRow(e.files[0].name, e.response.ErrorMessages, e.response.CurrentTime, "uploadRowSuccess", runCmd); } }And the question: Can I mark the operation as failed in the onSuccess handler ? Thanks Shimshon
public class InventoryObjectModel { public InventoryObjectModel() { } public Guid Id { get; set; } public string Name { get; set; } public Guid PlaceId { get; set; } public Guid? ParentId { get; set; } public string PlaceName { get; set; } public Guid CategoryId { get; set; } public string CategoryName { get; set; } public string Extra1 { get; set; } public string Extra2 { get; set; } public string Extra3 { get; set; } public string TagSerial { get; set; } public Guid nodeId { get; set; } public string NodeSerial { get; set; } }public class InventoryObjectController : Controller { // // GET: /Inventory/InventoryObject/ public ActionResult Index() { return View(); } public ActionResult GetInventory([DataSourceRequest] DataSourceRequest request) { var o = GetObjects(); DataSourceResult result = o.ToDataSourceResult(request); return Json(result, JsonRequestBehavior.AllowGet); } private List<InventoryObjectModel> GetObjects() { ... }
}@{ ViewBag.Title = "Inventory"; ViewBag.MainTitle = "Inventory"; Layout = "~/Views/Shared/_Layout.cshtml";}<div>
@(Html.Kendo().Grid<Noolibee.Presentation.Web.Administration.Areas.Inventory.Models.InventoryObjectModel>() .Name("Inventaire") .DataSource(dataSource => dataSource .Ajax() .Model(model => model.Id(p => p.Id)) .Read(read => read.Action("GetInventory", "InventoryObject")) .Events(events => events.Error("onError")) ) )</div><script> function onError(e, status) { if (e.errors) { var message = "The following errors have occurred:\n"; $.each(e.errors, function (key, value) { if (value.errors) { message += value.errors; } }); alert(message); } } </script>