Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi im trying to see if there is a better way to go about this. Im basically deleting an item from a jqGrid. Now this could obviously apply to any list. But is there a way to delete the entry and update the database without reloading the page, just refreshing the grid?

JavaScript
function onDeleteClient() {
    var url = '/Clients/Delete/';
    var clientId = jQuery('#client_grid').jqGrid('getGridParam', 'selrow');
    window.location.href = url + parseInt(clientId);
    $('#client_grid').trigger("reloadGrid", [{ page: 1}]);
};


C#
public ActionResult Delete(int id)
{
    var model = new ClientsModel();
    model.Delete(id);
    return RedirectToAction("Index");
}


so as you can see the controller will redirect it back to the original page and show the updated results. But is there a way we can update the controller and stay on the original page? Then i can just refresh the grid.

any pointers are appreciated...
Posted

1 solution

RedirectToAction("Index");
This will cause the entire page to refresh.
Try using partial views with an Ajax get/post call to do a partial page refresh.
 
Share this answer
 
Comments
Zerotimedev 15-Sep-13 23:18pm    
yep got that working, thanks, sometimes just need a suggestion to wake ur brain up lol thanks...

:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900