This is a migrated thread and some comments may be shown as answers.
Unable to refresh the Grid on delete
2 Answers 33 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anthony
Top achievements
Rank 1
Anthony asked on 22 Jan 2012, 07:30 PM
I have used the telerik grid which has a delete button in every row. The grid has a few pages, so i move to the 3rd or 4th page (could be any number). On click of the delete button (which is an image), I call a javascript function, which does an ajax postback to a service method, which returns a json boolean reply to me. Based on the value of this boolean variable, I either call a service method to delete the record or to deactivate it. The record is successfully deleted or deactivated from the db. However, this is not reflected in the Grid, until I do a physical refresh (F5). Please help me resolve this issue so that I can see the data refreshed on whichever page I may be.

//View
Html.Telerik().Grid<ModelType>()
                                .Name("Grid")
                                .Columns(columns =>
                                {
                                    columns.Bound(o => o.ID).Hidden(true);
                                    columns.Bound(o => o.Name).Title("Name")
                                   .... And So on ...
                                })
                            .DataBinding(dataBinding => dataBinding.Ajax()
                                .Select("_PartialView", "Controller")
                            .Pageable()
                            .Sortable()
                            .Scrollable(scrolling => scrolling.Height("373px")).Filterable()
                            .Render();


//Controller
 public ActionResult DeleteRecord(Guid id)
        {
            using (var client= new Client())
            {
                client.DeleteRecord(new request{ id= id });
            }
            return RedirectToAction("_PartialView");
        }

[GridAction]
        public ActionResult _PartialView()
        {
            var model = GetModelData();
            return View(new GridModel
            {
                Data = model
            });
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 23 Jan 2012, 09:08 AM
Hello Anthony,

You can use the client API method ajaxRequest to refresh the Grid's data.

All the best,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Anthony
Top achievements
Rank 1
answered on 23 Jan 2012, 11:36 AM
Thanks a lot! That worked! :)
Tags
Grid
Asked by
Anthony
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Anthony
Top achievements
Rank 1
Share this question
or