MVC-删除项目而不重新加载整个页面 [英] MVC - deleting items without reloading whole page
问题描述
功能 onDeleteClient(){
var url = ' /Clients/Delete/'跨度>;
var clientId = jQuery(' #client_grid').jqGrid(' getGridParam',' span> 借');
窗口.位置 .href = url + parseInt (clientId);
$(' #client_grid').trigger(" reloadGrid",[{页面: 公共 ActionResult Delete( int id)
{
var 模型= 新 ClientsModel();
model.Delete(id);
返回 RedirectToAction(" );
}
因此您可以看到控制器会将其重定向回原始页面并显示更新的结果.但是,有什么方法可以更新控制器并停留在原始页面上吗?然后,我可以刷新网格.
感谢任何指针...
(' #client_grid').trigger(" ,[{页面: 1 }]); };
公共 ActionResult Delete( int id) { var 模型= 新 ClientsModel(); model.Delete(id); 返回 RedirectToAction(" ); }
因此您可以看到控制器会将其重定向回原始页面并显示更新的结果.但是,有什么方法可以更新控制器并停留在原始页面上吗?然后,我可以刷新网格.
任何指针都值得赞赏...
RedirectToAction("Index");
这将导致整个页面刷新.
尝试将部分视图与Ajax get/post调用一起使用以进行部分页面刷新.
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...
('#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...
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.
这篇关于MVC-删除项目而不重新加载整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!