We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to refresh grid data after delete condition

Hi I'm curious about the delete button in grid.

my code is as follows.

@(Html.EJ().DataManager("dmPersonNames").URL("/Person/GetPersonNames").Adaptor(AdaptorType.UrlAdaptor)

...
.ClientSideEvents(e => { e.Create("onCreate").ActionBegin("onBegin").BeginEdit("onBeginEdit").EndEdit("onEndEdit")

.ActionComplete("onComplete").RowSelecting("cancelSelectionIfDisabled"); })


function onComplete(args) {

if (args.requestType == "delete") {




location.reload();

}

}

my Question is how to reload/refresh data in the grid from server after delete action.

the delete action does not delete the record under some conditions. so, I need to make sure the reload/refresh data in the grid from server again.

However, location.reload makes page flickering, so I'm looking for better solution.

Thank you very much.

Kind Regards,





2 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team June 8, 2017 12:07 PM UTC

Hi Dongil, 

Thanks for contacting Syncfusion support. 

According to your code example we found that you have used UrlAdaptor in Grid. In URL Adaptor you can map CRUD operation in Grid to Server-Side Controller action using the properties “InsertURL”, “UpdateURL” and “RemoveURL”. Once you perform delete operation in Grid it automatically call the dataSource URL and refresh the data in Grid.  
 
Find the code example and sample:  
 
 
@(Html.EJ().Grid<object>("HierarchyGrid") 
        .Datasource(ds => ds.URL("/Grid/Data").UpdateURL("/Grid/Update").InsertURL("/Grid/Insert").RemoveURL("/Grid/Delete").Adaptor(AdaptorType.UrlAdaptor)) 
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
        .AllowPaging() 
        ------------------------- 
       .Columns(col => 
        { 
            -------- 
       }) 
              
) 
 
---------------------------------------------------- 
public ActionResult Update(EditableOrder value) 
        { 
            OrderRepository.Update(value); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 
        //Insert action 
        public ActionResult Insert(EditableOrder value) 
        { 
            OrderRepository.Add(value); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 
        //Delete Action 
        public ActionResult Delete(int key) 
        { 
            OrderRepository.Delete(key); 
            return Json(key, JsonRequestBehavior.AllowGet); 
        } 


Regards, 
Prasanna Kumar N.S.V 
 



PK Prasanna Kumar Viswanathan Syncfusion Team June 8, 2017 12:11 PM UTC

Hi Dongil, 

Please ignore the previous update. 

According to your code example we found that you have used UrlAdaptor in Grid. In URL Adaptor you can map CRUD operation in Grid to Server-Side Controller action using the properties “InsertURL”, “UpdateURL” and “RemoveURL”. Once you perform delete operation in Grid it automatically call the dataSource URL and refresh the data in Grid.  
 
Find the code example and sample:  
 
 
@(Html.EJ().Grid<object>("HierarchyGrid") 
        .Datasource(ds => ds.URL("/Grid/Data").UpdateURL("/Grid/Update").InsertURL("/Grid/Insert").RemoveURL("/Grid/Delete").Adaptor(AdaptorType.UrlAdaptor)) 
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) 
        .AllowPaging() 
        ------------------------- 
       .Columns(col => 
        { 
            -------- 
       }) 
              
) 
 
---------------------------------------------------- 
public ActionResult Update(EditableOrder value) 
        { 
            OrderRepository.Update(value); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 
        //Insert action 
        public ActionResult Insert(EditableOrder value) 
        { 
            OrderRepository.Add(value); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 
        //Delete Action 
        public ActionResult Delete(int key) 
        { 
            OrderRepository.Delete(key); 
            return Json(key, JsonRequestBehavior.AllowGet); 
        } 


Regards, 
Prasanna Kumar N.S.V 
 


Loader.
Live Chat Icon For mobile
Up arrow icon