本文介绍了MVC-删除项目而不重新加载整个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在尝试查看是否有更好的方法可以解决此问题.我基本上是从jqGrid删除一个项目.现在,这显然可以适用于任何列表.但是,有没有一种方法可以删除条目并更新数据库而无需重新加载页面,而只是刷新网格?功能 onDeleteClient(){ var url = ' /Clients/Delete/'跨度>; var clientId = jQuery(' #client_grid').jqGrid(' getGridParam',' span> 借'); 窗口.位置 .href = url + parseInt (clientId); $(' #client_grid').trigger(" reloadGrid",[{页面: 1 }]); };
公共 ActionResult Delete( int id) { var 模型= 新 ClientsModel(); model.Delete(id); 返回 RedirectToAction(" 索引" ); }
因此您可以看到控制器会将其重定向回原始页面并显示更新的结果.但是,有什么方法可以更新控制器并停留在原始页面上吗?然后,我可以刷新网格.
感谢任何指针...
解决方案
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?
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}]); };
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...
解决方案
这篇关于MVC-删除项目而不重新加载整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!