This question is locked. New answers and comments are not allowed.
I'm having issue trying to rebind/update my grid after I delete a row.
View:
Controller:
Jquery code:
View:
@model Web.CMS.Mvc.Models.Asset.AssetListModel@(Html.Telerik().Grid(Model.Assets) .Name("AssetGrid") .DataKeys(k => k.Add(p => p.AssetID)) .DataBinding(db => db.Ajax() .Delete("DeleteAsset", "Asset") .Update("UpdateGalleryImage", "Asset") ) .Columns(col => { col.Bound(o => o.Title).Title("Title"); col.Template(@<text><img src="@Url.Content(ViewBag.ImagePath + @item.Location)" alt="Image" style="height: 100px; width: 200px;" /></text>); col.Command(commands => { commands.Edit(); commands.Delete(); }); }) .ClientEvents (events => events.OnComplete("Grid_OnComplete")))Controller:
public ActionResult DeleteAsset(string id) { Int32 GalleryImageID = Int32.Parse(id); Models.Asset.AssetModel _asset = Models.Asset.Repository.AssetMethods.GetAsset(GalleryImageID); if (_asset != null) { if (TryUpdateModel(_asset)) { try { Models.Asset.Repository.AssetMethods.DeleteAsset(_asset); .... ... .. . #endregion } catch(Exception ex) { Console.WriteLine(ex.Message); } } } // get all List<Models.Asset.AssetModel> _gallery = Models.Asset.Repository.AssetMethods.GetAssetsAll(_asset.PropertyID); // Rename existing Images and update DB List<Models.Asset.AssetModel> _newList = RenameFiles(_gallery, _asset.PropertyID); // Store Path to image in ViewBag for use in the View ViewBag.ImagePath = GetImagePath(_asset.PropertyID); //Rebind the grid return View(new GridModel(_newList));Jquery code:
function Grid_OnComplete(e) { if (e.name == "delete") { $("#" + e.currentTarget.id).data("tGrid").dataBind(e.response.data); grid.rebind(); } }