{"id":2499,"date":"2022-08-30T15:25:22","date_gmt":"2022-08-30T15:25:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/27\/kendo-ui-grid-batch-edit-after-saving-changes-microsoft-jscript-runtime-error-expected-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:25:22","modified_gmt":"2022-08-30T15:25:22","slug":"kendo-ui-grid-batch-edit-after-saving-changes-microsoft-jscript-runtime-error-expected-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/kendo-ui-grid-batch-edit-after-saving-changes-microsoft-jscript-runtime-error-expected-collection-of-common-programming-errors\/","title":{"rendered":"Kendo UI Grid Batch Edit After Saving Changes &#8211; Microsoft JScript runtime error: Expected &#39;;&#39;-Collection of common programming errors"},"content":{"rendered":"<p>I am using Kendo UI ASP.Net MVC &#8211; Grid &#8211; Batch Edit,<\/p>\n<p>Upon clicking &#8216;Save&#8217;. Data gets saved in database successfully.<\/p>\n<p>But &#8220;kendo.web.min.js&#8221; is throwing error &#8220;Microsoft JScript runtime error: Expected &#8216;;'&#8221;<\/p>\n<pre><code>@model IEnumerable\n@using Kendo.Mvc.UI;\n\n\n@(Html.Kendo().Grid(Model)\n    .Name(\"Grid\")\n    .Columns(columns =&gt;\n    {\n    columns.Bound(p =&gt; p.ID).Visible(false);\n    columns.Bound(p =&gt; p.ControllerName);\n    columns.Bound(p =&gt; p.ActionName);\n    columns.Bound(p =&gt; p.HasAccess);\n    columns.Bound(p =&gt; p.UserAccessID).Visible(false);\n    columns.Bound(p =&gt; p.ControllerID).Visible(false);\n    columns.Bound(p =&gt; p.ActionID).Visible(false);\n    })    \n    .Filterable()\n    .Groupable()\n    .Editable(editable =&gt; editable.Mode(GridEditMode.InCell))\n    .ToolBar(toolBar =&gt; { toolBar.Save(); })\n    .DataSource(dataSource =&gt; dataSource\n    .Ajax()\n    .Batch(true)\n    .Events(events =&gt; events.Error(\"error\"))            \n    .Update(update =&gt; update.Action(\"Edit\",\"ControllerActions\"))\n    .ServerOperation(false)\n    .Model(x =&gt;\n    {\n    x.Id(p =&gt; p.ID);\n    x.Field(p =&gt; p.ControllerName).Editable(false);\n    x.Field(p =&gt; p.ActionName).Editable(false);\n    x.Field(p =&gt; p.HasAccess).Editable(true);\n    })\n    )\n)\n\n\n[HttpPost]\npublic ActionResult Edit([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = \"models\")] IEnumerable controllerActionViewModel)\n{\n            try\n            {\n                if (controllerActionViewModel != null &amp;&amp; ModelState.IsValid)\n                {\n                    foreach (var item in controllerActionViewModel)\n\n\n {\n                db.Database.ExecuteSqlCommand(\"SaveUserAccess @UserID,@ControllerID,@ActionID,@UserAccessID,@HasAccess\",\n                               new SqlParameter(\"UserID\", item.UserID),\n                               new SqlParameter(\"ControllerID\", item.ControllerID),\n                               new SqlParameter(\"ActionID\", item.ActionID),\n                               new SqlParameter(\"UserAccessID\", item.UserAccessID),\n                               new SqlParameter(\"HasAccess\", item.HasAccess)\n                               );\n            }\n\n        }\n    }\n    catch (Exception ex)\n    {\n        Helper.SaveError(ex.InnerException.InnerException.Message, \"ControllerActions\", \"Edit\");\n        ModelState.AddModelError(string.Empty, ex.InnerException.InnerException.Message);\n    }\n\n    return Json(new[] { controllerActionViewModel }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);\n}\n<\/code><\/pre>\n<ol>\n<li>\n<p>I think I may have discovered the answer to this problem, having wrestled with it for a good part of today.<\/p>\n<p>My code looked very similar to yours. The return value of my action method looked like this:<\/p>\n<pre><code>return Json(new[] { viewmodel }.ToDataSourceResult(request, ModelState));\n<\/code><\/pre>\n<p>This gave me the exact javascript error you describe. After trying many things, I eventually compared the code to another method that was working fine and so I adjusted it slightly to this:<\/p>\n<pre><code>return Json(viewmodel.ToDataSourceResult(request, ModelState));\n<\/code><\/pre>\n<p>This is now working and my MVC application is no longer throwing the javascript error.<\/p>\n<p>I hope this helps you @Jignesh.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-27 08:37:59. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am using Kendo UI ASP.Net MVC &#8211; Grid &#8211; Batch Edit, Upon clicking &#8216;Save&#8217;. Data gets saved in database successfully. But &#8220;kendo.web.min.js&#8221; is throwing error &#8220;Microsoft JScript runtime error: Expected &#8216;;&#8217;&#8221; @model IEnumerable @using Kendo.Mvc.UI; @(Html.Kendo().Grid(Model) .Name(&#8220;Grid&#8221;) .Columns(columns =&gt; { columns.Bound(p =&gt; p.ID).Visible(false); columns.Bound(p =&gt; p.ControllerName); columns.Bound(p =&gt; p.ActionName); columns.Bound(p =&gt; p.HasAccess); columns.Bound(p =&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2499","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2499"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2499\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}