This question is locked. New answers and comments are not allowed.
Hi,
I want to use the Grid with Ajax binding. Initially the grid is diplayed correctly. When updating, the Action method is called, but when I return the updated GridModel the Grid seems to bind the rows, but all columns are empty. What I am doing wrong ?
Grid in View:
I want to use the Grid with Ajax binding. Initially the grid is diplayed correctly. When updating, the Action method is called, but when I return the updated GridModel the Grid seems to bind the rows, but all columns are empty. What I am doing wrong ?
Grid in View:
Html.Telerik().Grid(Model) .Name("Grid") .DataKeys(keys => { keys.Add( g => g.Id ); }) .Columns(columns => { columns.Template(@<text> <a href="@Url.Action("Up", new { GalleryId = @item.GalleryId, ImageId = @item.Id })"><img src="@Url.Content("~/Content/Images/active.png")" alt="Nach oben"/></a> <a href="@Url.Action("Down", new { GalleryId = @item.GalleryId, ImageId = @item.Id })"><img src="@Url.Content("~/Content/Images/inactive.png")" alt="Nach oben"/></a> </text>).Width(40); columns.Template(@<text> <img alt='@item.FilePath' src='@item.FilePath?width=200&height=200' style= 'vertical-align:middle;'/> </text>) .HeaderTemplate(@<text><input type="image" src="@Url.Content("~/Content/Images/add.png")" alt="Bild" onclick="openDialog();return false;"/></text>) .Width(210); columns.Template(@<text><h3>@item.Title</h3><p>@item.Description</p></text>).Title("Titel / Beschreibung"); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.Image); }); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_CustomBinding", "Gallery", new { id = @ViewBag.AlbumId } ) .Update("_SaveGalleryItem", "Gallery" )) .Editable(editing => editing.Mode(GridEditMode.PopUp)) .Sortable(sorting => sorting.OrderBy( sortOrder => sortOrder.Add( o => o.SortNr ).Ascending() ) ) .Render();Initial Action for filling Grid:
Action for Ajax Edit:
public ActionResult EditGallery(Guid id)
{ var lstImages = PrepareForImageView(id, _galleryRepository.ListImages(id)); return View(lstImages);
}Action for Ajax Edit:
[AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveGalleryItem(FormCollection collection) { Guid id = new Guid(collection["id"]); var image = _galleryRepository.GetImage(id); image.Title = collection["Title"] == null ? string.Empty : collection["Title"].ToString(); image.Description = collection["Description"] == null ? string.Empty : collection["Description"].ToString(); _galleryRepository.SaveChanges(); var lstImages = PrepareForImageView(image.GalleryId, _galleryRepository.ListImages(image.GalleryId)); return View(new GridModel(lstImages)); }