
I have Grid code like
this (UI)
@(Html.Kendo().Grid<ATS.RoleManager.Models.TasksAndPaths.EscalationRolePath>()
.Name("GridTaskAndPaths")
.Columns(columns => {
columns.Bound(p => p.TaskEscalationRolePathId);
columns.Bound(p => p.PathDescription).EditorTemplateName("EscalationRolePathsDropDownList");
})
//.ToolBar(toolBar => toolBar.Save())
.Editable(editable
=> editable.Mode(GridEditMode.InCell))
.Events(ev => ev.Save(@"function(e){
setTimeout(function(){ $('#GridTaskAndPaths').data('kendoGrid').dataSource.sync()
}
)}"))
.Scrollable()
.Pageable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model => {
model.Id(p => p.TaskEscalationRolePathId);
})
.Read(read => read.Action("HierarchyBinding_Employees", "TasksAndPaths"))
.Update(update => update.Action("EditingCustom_Update", "TasksAndPaths"))
)
)
<script>
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
</script>
--------------------------------------------------------------------------------------
Partial View
Views\Shared\EditorTemplates\EscalationRolePathsDropDownList.cshtml
@using Kendo.Mvc.UI;
@(Html.Kendo().DropDownList()
.Name("PathDescription") //Important, must match the column's name
.OptionLabel("Select path")
.DataValueField("TaskEscalationRolePathId")
.DataTextField("PathDescription")
.BindTo((System.Collections.IEnumerable)ViewBag.EscalationPathName )
)
---------------------------------------------------------------------------------------
Controller Code
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<EscalationRolePath> escalationRolePath)
{
//Here is the issue , object escalationRolePath is not null but values (fields ) are NULL
}
public JsonResult HierarchyBinding_AllRoles(string TaskEscalationRolePathId, [DataSourceRequest] DataSourceRequest request)
{
try
{
return new JsonResult { Data = GetListOfEmployeesAndRolesOnEscalationPath(TaskEscalationRolePathId).ToDataSourceResult(request), MaxJsonLength = Int32.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
catch (Exception ex)
{
ExceptionLogger.LogUIException(ex);
return null;
}
}
Please suggest me solution for this .
Majid
8 Answers, 1 is accepted
From the provided information it seems that the "kendo.aspnetmvc" script is not included in the project as it converts the data in order to be understand by the MVC controller. Could you please check if the script is correctly included and let us know of the result?
Vladimir Iliev
Telerik

I am experiencing the same problem and I have included kendo.aspnetmvc.
here's my code:
View
@(Html.Kendo().Grid<
TelerikMVC4.Models.ProductViewModel
>()
.Name("grid")
.Events(e => e.DataBound("onDataBound"))
.HtmlAttributes(new { style = "font-size: 12px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px;" })
.Columns(columns =>
{
columns.Bound(p => p.ProductName);
columns.Bound(p => p.Category).ClientTemplate("#=Category.CategoryName#").Width(260);
columns.Bound(p => p.UnitPrice).Width(120);
})
.ToolBar(toolBar =>
{
toolBar.Template(@<
text
>
<
div
style
=
"float: left; margin-top: 5px;"
>
@Html.Kendo().Button().Name("btnNew").Icon("plus").Content("Novi").Events(builder => builder.Click("insertMode"))
@Html.Kendo().Button().Name("btnEdit").Icon("pencil").Content("Izmijeni").Events(builder => builder.Click("editMode"))
@Html.Kendo().Button().Name("btnDelete").Icon("close").Content("Obriši").Events(builder => builder.Click("deleteItem"))
@Html.Kendo().Button().Name("btnUpdate").Icon("tick").Content("Update").Events(builder => builder.Click("updateGridItem"))
@Html.Kendo().Button().Name("btnSave").Icon("tick").Content("Save").Events(builder => builder.Click("insert"))
</
div
>
<
div
style
=
"float: right"
>
<
input
class
=
'k-textbox'
id
=
'searchbox'
style
=
"width: 250px;"
placeholder
=
'Unesite rijec za pretragu...'
/>
@Html.Kendo().Button().Icon("search").Name("searchbutton").Content("Pretraga")
</
div
>
</
text
>);
})
.Editable(editable => editable.Mode(GridEditMode.InLine)
.Window(window=>
{
window.Width(760);
window.Title("Products");
})
)
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.ProductID);
model.Field(p => p.ProductID).Editable(false);
model.Field(p => p.Category).DefaultValue(
ViewData["defaultCategory"] as TelerikMVC4.Models.CategoryViewModel);
})
.PageSize(20)
.Read(read => read.Action("Products_Read", "Product").Data("addSearch"))
.Create(create => create.Action("EditingCustom_Create", "Product"))
.Update(update => update.Action("EditingCustom_Update", "Product"))
.Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Product"))
)
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Events(events => events.Change("dgChange"))
)
<
script
type
=
"text/javascript"
>
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
function onDataBound(e) {
if (this.dataSource.view().length == 0) {
var currentPage = this.dataSource.page();
if (currentPage > 1) {
e.preventDefault();
this.dataSource.page(currentPage - 1);
}
}
}
function dgChange() {
var grid = $('#grid').data('kendoGrid');
var rows = grid.select().each(function () {
var dataItem = grid.dataItem($(this));
id = dataItem.TeacherID;
});
}
function addSearch() {
return { searchbox: $('#searchbox').val() };
}
$('#searchbutton').click(function () {
$('#grid').data('kendoGrid').dataSource.read();
});
function dgChange() {
var grid = $('#grid').data('kendoGrid');
var rows = grid.select().each(function () {
var dataItem = grid.dataItem($(this));
id = dataItem.ProductID;
});
}
function editMode() {
var grid = $('#grid').data('kendoGrid');
var selected = grid.select();
if (selected.length > 0) {
grid.editRow(selected);
}
}
function insertMode() {
var grid = $('#grid').data('kendoGrid');
grid.addRow();
grid.select(0);
}
function insert() {
var grid = $('#grid').data('kendoGrid');
grid.editRow($("#grid tr:eq(1)"));
grid.saveRow();
}
function updateGridItem() {
var grid = $('#grid').data('kendoGrid');
var selected = grid.select();
if (selected.length > 0) {
grid.saveRow(selected);
}
}
function deleteItem() {
var grid = $('#grid').data('kendoGrid');
var selected = grid.select();
if (selected.length > 0)
{
grid.removeRow(selected);
}
}
</
script
>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using TelerikMVC4.Models;
using TelerikMVC4.Models.Services;
namespace TelerikMVC4.Controllers
{
public class ProductController : Controller
{
ProductService productService = new ProductService(new NorthwindEntities());
public ActionResult Index()
{
PopulateCategories();
return View();
}
public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request, string searchbox)
{
return Json(productService.Read(searchbox).ToDataSourceResult(request));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Update([DataSourceRequest] DataSourceRequest request,
[Bind(Prefix = "models")]IEnumerable<
ProductViewModel
> products)
{
if (products != null && ModelState.IsValid)
{
foreach (var product in products)
{
productService.Update(product);
}
}
return Json(products.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Create([DataSourceRequest] DataSourceRequest request,
[Bind(Prefix = "models")]IEnumerable<
ProductViewModel
> products)
{
var results = new List<
ProductViewModel
>();
if (products != null && ModelState.IsValid)
{
foreach (var product in products)
{
productService.Create(product);
results.Add(product);
}
}
return Json(results.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Destroy([DataSourceRequest] DataSourceRequest request,
[Bind(Prefix = "models")]IEnumerable<
ProductViewModel
> products)
{
foreach (var product in products)
{
productService.Destroy(product);
}
return Json(products.ToDataSourceResult(request, ModelState));
}
private void PopulateCategories()
{
var dataContext = new NorthwindEntities();
var categories = dataContext.Categories
.Select(c => new CategoryViewModel
{
CategoryID = c.CategoryID,
CategoryName = c.CategoryName
})
.OrderBy(e => e.CategoryName);
ViewData["categories"] = categories;
ViewData["defaultCategory"] = categories.First();
}
}
}
From the provided information it seems that the "Batch" option of the DataSource is not set to true:
.DataSource(dataSource => dataSource
.Ajax()
.Batch(
true
)
Regards,
Vladimir Iliev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

My CSHTML
________________________________________________________________________________________________________
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Planogram Worksheet";
}
<div class="container-fluid">
<div class="k-header">
@*<h1>Project Title</h1>*@
<div id="responsive-panel">
@(Html.Kendo().Menu()
.Name("Menu")
.Items(items =>
{
items.Add().Text(" ").Action("ViewPlanogram", "ActualPlanogram").ImageUrl("~/Images/images1.png");
items.Add().Text("Actual Planogram").Action("ViewPlanogram", "ActualPlanogram");
items.Add().Text("Planogram Worksheet").Action("ViewPlanogram", "PlanogramWorksheet").Selected(true);
items.Add().Text("Maintenance").Items(subItem =>
{
subItem.Add().Text("Panel Cloning").Action("Index", "MaintenancePanelCloning");
subItem.Add().Text("Panel Maintenance").Items(subPanel =>
{
subPanel.Add().Text("Add Panels To Location");
subPanel.Add().Text("Drop Panels");
subPanel.Add().Text("Rename Panels");
subPanel.Add().Text("Drop Items From All Panels");
}
);
subItem.Add().Text("Location Maintenance");
subItem.Add().Text("Supplier Maintenance");
}
);
items.Add().Text("Commit").Action("ViewCommit", "Commit");
//items.Add().Text("Commit").Items(subItem =>
//{
// subItem.Add().Text("Commit Department");
// subItem.Add().Text("Commit Supplier");
//}
// );
items.Add().Text("Reports").Action("ViewReports", "Reports");
}).HighlightPath(false)
)
</div>
@*<button id="configure" class="k-rpanel-toggle k-button k-primary btn-toggle"><span class="k-icon k-i-hbars"></span></button>*@
</div>
</div>
<div>
<div class="col-xs-18 col-md-12 placeholder">
@(Html.Kendo().Grid<Planogram.Models.PlanogramWorksheetModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ItemNumber).Width(135);
columns.Bound(p => p.ItemDesc).Width(200);
columns.Bound(p => p.Panel).Width(150);
columns.Bound(p => p.Department).Width(200);
columns.Bound(p => p.Row).Width(100);
columns.Bound(p => p.Column).Width(100);
columns.Bound(p => p.SupplierName).Width(400);
columns.Bound(p => p.Facings).Width(100);
columns.Bound(p => p.Decision).Width(150);
columns.Bound(p => p.Comments).Width(200);
columns.Bound(p => p.User).Width(100);
columns.Bound(p => p.Add_Check).Hidden();
columns.Bound(p => p.Area_Name).Hidden();
columns.Bound(p => p.Area_Nbr).Hidden();
columns.Bound(p => p.Commit_Changed).Hidden();
columns.Bound(p => p.DepartmentID).Hidden();
columns.Bound(p => p.FromDate).Hidden();
columns.Bound(p => p.id).Hidden();
columns.Bound(p => p.Loc_item).Hidden();
columns.Bound(p => p.Loc_panel).Hidden();
columns.Bound(p => p.Loc_panel_item).Hidden();
columns.Bound(p => p.Location_Name).Hidden();
columns.Bound(p => p.Location_Nbr).Hidden();
columns.Bound(p => p.PanelID).Hidden();
columns.Bound(p => p.Selecting).Hidden();
columns.Bound(p => p.SupplierNbr).Hidden();
columns.Bound(p => p.ToDate).Hidden();
columns.Bound(p => p.Unique_ID).Hidden();
columns.Bound(p => p.VerifyADD).Hidden();
columns.Bound(p => p.VersionNbr).Hidden();
columns.Bound(p => p.WorkingDate).Hidden();
})
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<div>
@(Html.Kendo().DropDownList()
.Events(events => events.Change("ClearGrid"))
.Name("Area")
.DataTextField("Area_nm")
.DataValueField("Area_nbr")
.HtmlAttributes(new { style = "width: 300px ; text-align:center" })
.DataSource(s =>
{
s.Read(r =>
{
r.Action("GetArea", "PlanogramWorksheet");
})
.ServerFiltering(true);
})
.HeaderTemplate("<div class=\"dropdown-header k-widget k-header\" style=\"background-color:darkgrey\">" +
"<span>Area ID - </span>" +
"<span>Area Name</span>" +
"</div>")
.OptionLabel("--Select Area--")
)
@(Html.Kendo().DropDownList()
.Events(events => events.Change("ClearGrid"))
.Name("Location")
.DataTextField("Location_nm")
.DataValueField("Location_nbr")
.HtmlAttributes(new { style = "width: 300px ; text-align:center" })
.DataSource(s =>
{
s.Read(r =>
{
r.Action("GetLocation", "PlanogramWorksheet")
.Data("filterLocation");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.HeaderTemplate("<div class=\"dropdown-header k-widget k-header\" style=\"background-color:darkgrey\">" +
"<span>Location ID - </span>" +
"<span>Location Name</span>" +
"</div>")
.OptionLabel("--Select Location--")
.CascadeFrom("Area")
)
<script>
function filterLocation() {
return {
area: $("#Area").val()
};
}
</script>
@(Html.Kendo().DropDownList()
.Events(events => events.Change("ClearGrid"))
.Name("Department")
.DataTextField("Department_nm")
.DataValueField("DepartmentID")
.HtmlAttributes(new { style = "width: 300px ; text-align:center" })
.DataSource(s =>
{
s.Read(r =>
{
r.Action("GetDepartment", "PlanogramWorksheet")
.Data("filterDepartment");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.HeaderTemplate("<div class=\"dropdown-header k-widget k-header\" style=\"background-color:darkgrey\">" +
"<span>Department ID - </span>" +
"<span>Department Name</span>" +
"</div>")
.OptionLabel("--Select Department--")
.CascadeFrom("Location")
)
<script>
function filterDepartment() {
return {
//area:$("#Area").val(),
location: $("#Location").val()
};
}
</script>
@(Html.Kendo().DropDownList()
.Events(events => events.Change("OnDdlChange"))
.Name("Panel")
.DataTextField("Panel_nm")
.DataValueField("Panel_nm")
.HtmlAttributes(new { data_value_primitive = "true", style = "width: 300px ; text-align:center" })
.DataSource(s =>
{
s.Read(r =>
{
r.Action("GetPanel", "PlanogramWorksheet")
.Data("filterPanel");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.HeaderTemplate("<div class=\"dropdown-header k-widget k-header\" style=\"background-color:darkgrey\">" +
"<span>Panel</span>" +
"</div>")
.OptionLabel("--Select Panel--")
.CascadeFrom("Department")
)
<script>
function filterPanel() {
return {
//area: $("#Area").val(),
location: $("#Location").val(),
department: $("#Department").val()
};
}
</script>
</div>
@item.SaveButton()
</text>);
})
.Editable(e => e.Mode(GridEditMode.InCell))
.Pageable()
.AutoBind(false)
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:670px" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Model(m => m.Id(p => p.id))
.PageSize(100)
.Read(read => read.Action("Planogram_Read", "PlanogramWorksheet").Data("getDdls"))
.Update(read => read.Action("Planogram_Update", "PlanogramWorksheet"))//.Data("getDdls"))
)
)
<script>
function getDdls() {
return {
location: $("#Location").val(),
panel: $("#Panel ").val(),
area: $("#Area").val(),
department: $("#Department").val()
}
}
function ClearGrid() {
$("#grid").data("kendoGrid").dataSource.data([]);
}
function OnDdlChange() {
$("#grid").data("kendoGrid").dataSource.read();
}
</script>
</div>
</div>
______________________________________________________________________________________________________
My Controller
______________________________________________________________________________________________________
public ActionResult Planogram_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<PlanogramWorksheetModel> newplan)
{
if (newplan != null && ModelState.IsValid)
{
foreach (var plan in newplan)
{
var entity = new WD_tbl_Working_Table();
entity.Add_Check = plan.Add_Check;
entity.Area_Name = plan.Area_Name;
entity.Area_Nbr = plan.Area_Nbr;
entity.Clmn = plan.Column;
entity.Comments = plan.Comments;
entity.Commit_Changed = plan.Commit_Changed;
entity.Decision = plan.Decision;
entity.Department = plan.Department;
entity.DepartmentID = plan.DepartmentID;
entity.Facings = plan.Facings;
entity.FromDate = plan.FromDate;
entity.id = plan.id;
entity.Item_Desc = plan.ItemDesc;
entity.Item_Number = plan.ItemNumber;
entity.Loc_item = plan.Loc_item;
entity.Loc_panel = plan.Loc_panel;
entity.Loc_panel_item = plan.Loc_panel_item;
entity.Location_Name = plan.Location_Name;
entity.Location_Nbr = plan.Location_Nbr;
entity.Panel = plan.Panel;
entity.PanelID = plan.PanelID;
entity.Row = plan.Row;
entity.Selecting = plan.Selecting;
entity.SupplierName = plan.SupplierName;
entity.SupplierNbr = plan.SupplierNbr;
entity.ToDate = plan.ToDate;
entity.Unique_ID = plan.Unique_ID;
entity.UserID = userName;
entity.VerifyADD = plan.VerifyADD;
entity.VersionNbr = plan.VersionNbr;
entity.WorkingDate = plan.WorkingDate;
//entities.WD_tbl_Working_Table.Attach(entity);
entities.Entry(entity).State = EntityState.Modified;
entities.SaveChanges();
}
}
return Json(newplan.ToDataSourceResult(request, ModelState));
}
________________________________________________________________________________________________________
I have attached all the required scripts, When i remove "[Bind(Prefix = "models")]" from the controller function it works, but it is passing only null. if i add"[Bind(Prefix = "models")]" then function is not getting called.
Please help me ASAP.
Thanks,
Abilash
From the provided information it seems that the "kendo.aspnetmvc.min.js" script is missing - could you please make sure it's correctly included after the "kendo.all.min.js" script? If this is not the case could you please submit new support ticket / forum post and provide runable example where the issue is reproduced? This would help us pinpoint the exact reason for current behavior.
Regards,
Vladimir Iliev
Telerik

I have added all required attachments in appropriate order, I found out the problem, I have X Y Z columns and only Y is editable..
So X is a string type, If X contains string with character like '<' or '>' i am not able to edit that row, Rest of the rows i am able to edit.
As the described behavior is not related to the original topic of this support conversation, could you please open a new support ticket / forum post for it? In this way it is much easier to follow and concentrate on the particular issue which usually leads to its faster resolving.
Regards,
Vladimir Iliev
Telerik