Trying to implement inline editing. Following is a simplified version.
EmployeeEditor.cshtml inside EditorTemplates folder
@(Html.Kendo().DropDownList()
.Name("ToBranch")
.DataValueField("Id")
.DataTextField("Name")
.BindTo((System.Collections.IEnumerable)ViewData["toBranch"])
)
Employee class
public class Employee
{
public string EmployeeName {get; set;}
[UIHint("EmployeeEditor"]
public string ToBranch {get; set;}
}
View
@Html.Kendo().Grid(Model.Employees)
.Name("BranchGrid")
.Columns(col =>
{
col.Bound(o => o.EmployeeName);
col.Bound(o => o.ToBranch);
col.Command(command => { command.Edit(); });
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Field(o => o.EmployeeName).Editable(false);
})
.Update(update => update.Action("EditingInline_Update", "BranchForm"))
.ServerOperation(false))
.Events(events => events.DataBound("error_handler"))
.Render();
Controller
public ActionResult Index()
{
//Populate a model
ViewData["toBranch"] = branches
return View(model);
}
/////// Important Part
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, Employee model)
{
//// If there was a branch initially say 24 and I change it to 28, I do see model.ToBranch as 28 ( works fine)
//// However, if the branch was initially an empty string and I change it to 28, model.ToBranch is "[Object object]"
}
Can you please tell me why this is happening? This is kind of critical and an urgent reply would be really appreciated