This question is locked. New answers and comments are not allowed.
Hi, I have a grid with inCell editing. I've made it pretty much similar to the example in your web, but for some reason, inputs that are strings don't retain their values after they lose focus (changes are reverted). Here's the code
and here's the controller
as you can see, the code is almost equal yours in the samples, but for some reason, when I modify, for example, field NombrePartido (in english StateName), when I left the input, the value of it reverts to its original value. That behaviour doesn't happen on Integer o Decimal fields where changes are saved.
Thanks for your help and for this amazing product
@model IEnumerable<Ejecucion.Dominio.Entities.Partido>@{ ViewBag.Title = "Index";}<div class="formulario" style="width: 80%"> <h2>Lista de partidos</h2> @{Html.Telerik().Grid(Model) .TableHtmlAttributes(new { style = "table-layout:fixed" }) .Name("grillapartidos") .DataKeys(keys => keys.Add(av => av.Id)) .ToolBar(commands => { commands.Insert(); commands.SubmitChanges(); }) .Columns(columns => { columns.Bound(p => p.NombrePartido); columns.Bound(p => p.SeccionElectoral); columns.Bound(p => p.NombreIntendente); columns.Bound(p => p.CantidadHabitantes); }) .KeyboardNavigation(kbd => kbd.EditOnTab(true)) .DataBinding(dataBinding => dataBinding.Ajax() .Select("_SelectBatchEditing", "Partidos") .Update("_SaveBatchEditing", "Partidos") ) .Editable(edit => edit.Mode(GridEditMode.InCell)) .Render(); }</div>and here's the controller
namespace Ejecucion.Controllers{ public class PartidosController : Controller { private IPartidosRepository db = new PartidosRepository(); // // GET: /Partidos/ public ViewResult Index() { return View(db.GetAll().ToList()); } [GridAction] public ActionResult _SelectBatchEditing() { var partidos = db.GetAll(); return View(new GridModel(partidos.ToList())); } [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveBatchEditing([Bind(Prefix = "inserted")]IEnumerable<Partido> insertedItems, [Bind(Prefix = "updated")]IEnumerable<Partido> updatedItems, [Bind(Prefix = "deleted")]IEnumerable<Partido> deletedItems) { if (insertedItems != null) { foreach (var item in insertedItems) { db.Add(item); } } if (updatedItems != null) { foreach (var item in updatedItems) { var target = db.Get(item.Id); if (target != null) { target.NombrePartido = item.NombrePartido; target.NombreIntendente = item.NombreIntendente; target.CantidadHabitantes = item.CantidadHabitantes; target.SeccionElectoral = item.SeccionElectoral; db.Modify(target); } } } if (deletedItems != null) { foreach (var item in deletedItems) { db.Remove(item); } } var partidos = db.GetAll(); return View(new GridModel(partidos.ToList())); }as you can see, the code is almost equal yours in the samples, but for some reason, when I modify, for example, field NombrePartido (in english StateName), when I left the input, the value of it reverts to its original value. That behaviour doesn't happen on Integer o Decimal fields where changes are saved.
Thanks for your help and for this amazing product